-
-
Notifications
You must be signed in to change notification settings - Fork 3
Support ?Sized types in Rng*: TryRng* blanket impls
#51
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,10 @@ pub trait RngCore: TryRngCore<Error = Infallible> { | |
| fn fill_bytes(&mut self, dst: &mut [u8]); | ||
| } | ||
|
|
||
| impl<R: TryRngCore<Error = Infallible>> RngCore for R { | ||
| impl<R> RngCore for R | ||
| where | ||
| R: TryRngCore<Error = Infallible> + ?Sized, | ||
| { | ||
| #[inline] | ||
| fn next_u32(&mut self) -> u32 { | ||
| match self.try_next_u32() { | ||
|
|
@@ -86,9 +89,9 @@ impl<R: TryRngCore<Error = Infallible>> RngCore for R { | |
| /// | ||
| /// This is a convenient trait alias for <code>[TryCryptoRng]<Error = [Infallible]></code>. | ||
| /// It is equivalent to the trait sum <code>[RngCore] + [TryCryptoRng]</code>. | ||
| pub trait CryptoRng: TryCryptoRng<Error = Infallible> {} | ||
| pub trait CryptoRng: RngCore + TryCryptoRng<Error = Infallible> {} | ||
|
Comment on lines
-89
to
+92
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting that this is necessary; it seems to indicate a trait solver issue. But simple solutions are good!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think having explicit bounds even if they're covered by a blanket impl makes the compiler errors much better, because it will tell you explicitly why the bound wasn't satisfied, whereas figuring out why a blanket impl didn't work can be a lot of red herrings |
||
|
|
||
| impl<R: TryCryptoRng<Error = Infallible>> CryptoRng for R {} | ||
| impl<R> CryptoRng for R where R: TryCryptoRng<Error = Infallible> + ?Sized {} | ||
dhardy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// Base trait for random number generators and random data sources | ||
| /// | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.