-
-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
autoimpl supports |
CHANGELOG.md
entrySummary
Adds a
Clone
bound 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
Clone
bound. You can just as easily create a new one withDefault
and 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.