Require SeedableRng::Seed to impl Clone#1491
Conversation
|
Actually considering adding Honestly, I kinda wish that the seed parameter were just |
This design decision comes from a while back... but it appears that we still need an incomplete nightly-only feature to do this: #![feature(generic_const_exprs)]
pub trait Seedable {
const BYTES: usize;
fn from_seed(seed: [u8; Self::BYTES]) -> Self;
}
struct MyRng;
impl Seedable for MyRng {
const BYTES: usize = 12;
fn from_seed(seed: [u8; 12]) -> Self {
todo!()
}
} |
|
Yeah, the best workaround would be to use something like |
|
I don't think we want to use In the mean-time, please do add an |
|
Finally got to this, but now I updated the description slightly since |
|
autoimpl supports |
CHANGELOG.mdentrySummary
Adds a
Clonebound toSeedableRng::Seed.Motivation
Simply put: it's already possible to clone these seeds based upon the bounds already provided, but it's really annoying without a proper
Clonebound. You can just as easily create a new one withDefaultand write all of the data from the old seed into the new one withAsMut, but this now requires me to do this explicitly instead of just being able toderive(Clone)on a struct that contains a seed.Details
This is also a breaking change, but I don't think people will have a problem including it in the next breaking release.