Support ?Sized types in Rng*: TryRng* blanket impls#51
Conversation
Adds `?Sized` to the bounds of the blanket impls, so unsized types can also be used by way of the blanket impl. See also: #45
baloo
left a comment
There was a problem hiding this comment.
Downsteam changes with that:
RustCrypto/SSH#453
Without:
RustCrypto/formats#2175
|
Well this is interesting: It seems like if it were: pub trait CryptoRng: RngCore {}instead of pub trait CryptoRng: TryRngCore<Error = Infallible> {...then the entire problem just goes away without having to add an explicit Edit: aah nope, I think it still needs this change as well to be able to work with trait objects, and we still need a pub trait CryptoRng: RngCore + TryCryptoRng<Error = Infallible> {}...which will ensure/test that a I will save that for a followup though, so as not to muddy the issue, unless everyone likes it. |
|
@baloo yeah, we use @dhardy I don't suppose it would be possible to get another prerelease out with this PR (and possibly with the added |
|
Yeah it's a much better solution than having to add the RngCore to every consumer. An RC would really be appreciated! |
|
I went ahead and did the bounds change I proposed above in 9966877: pub trait CryptoRng: RngCore + TryCryptoRng<Error = Infallible> {}It's just more explicit and ensures that if a I kept it in a separate commit in case you just want the |
dhardy
left a comment
There was a problem hiding this comment.
I have no problem with this change. I'll make a new release later (not much time now).
| pub trait CryptoRng: TryCryptoRng<Error = Infallible> {} | ||
| pub trait CryptoRng: RngCore + TryCryptoRng<Error = Infallible> {} |
There was a problem hiding this comment.
Interesting that this is necessary; it seems to indicate a trait solver issue.
But simple solutions are good!
There was a problem hiding this comment.
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
Adds
?Sizedto the bounds of the blanket impls, so unsized types can also be used by way of the blanket impl.See also: #45