-
-
Notifications
You must be signed in to change notification settings - Fork 481
New rand_core utility fns + Generator trait #1688
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
base: master
Are you sure you want to change the base?
Conversation
| impl<R, Rsdr> ReseedingRng<R, Rsdr> | ||
| impl<R: fmt::Debug, Rsdr: fmt::Debug> fmt::Debug for ReseedingRng<R, Rsdr> |
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.
This needed an explicit impl because it needs an additional where clause: R::Result: Debug
| fn next_u32(&mut self) -> u32 { | ||
| self.0.next_u32() | ||
| let Self { core, buffer } = self; | ||
| // NOTE: this fn always returns one word, thus cannot return u32 for any W: Word | ||
| le::next_word_via_gen_block(buffer, |block| core.generate(block)) | ||
| } | ||
|
|
||
| #[inline(always)] | ||
| #[inline] | ||
| fn next_u64(&mut self) -> u64 { | ||
| self.0.next_u64() | ||
| let Self { core, buffer } = self; | ||
| // NOTE: this fn is specific to u32 buffers | ||
| le::next_u64_via_gen_block(buffer, |block| core.generate(block)) | ||
| } |
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.
Unfortunately the available le fns require us to fix W = u32. It would be nice if we could impl ReseedingRng for any W: Word but I don't think there are enough block-RNGs over u64 for this to be a blocking issue.
Draft over #1686 to use the
Generatortrait.Mostly only
chacha.rsandreseeding.rsdiffer from #1686.Performance is now in-line with the old
blockcode: