Skip to content

Commit c14a054

Browse files
committed
Support ?Sized types in Rng*: TryRng* blanket impls
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
1 parent 9dabe12 commit c14a054

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ pub trait RngCore: TryRngCore<Error = Infallible> {
5959
fn fill_bytes(&mut self, dst: &mut [u8]);
6060
}
6161

62-
impl<R: TryRngCore<Error = Infallible>> RngCore for R {
62+
impl<R> RngCore for R
63+
where
64+
R: TryRngCore<Error = Infallible> + ?Sized,
65+
{
6366
#[inline]
6467
fn next_u32(&mut self) -> u32 {
6568
match self.try_next_u32() {
@@ -88,7 +91,7 @@ impl<R: TryRngCore<Error = Infallible>> RngCore for R {
8891
/// It is equivalent to the trait sum <code>[RngCore] + [TryCryptoRng]</code>.
8992
pub trait CryptoRng: TryCryptoRng<Error = Infallible> {}
9093

91-
impl<R: TryCryptoRng<Error = Infallible>> CryptoRng for R {}
94+
impl<R> CryptoRng for R where R: TryCryptoRng<Error = Infallible> + ?Sized {}
9295

9396
/// Base trait for random number generators and random data sources
9497
///

0 commit comments

Comments
 (0)