From c14a054f8d933b2db42d21d10a968d5aa6044e60 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Mon, 19 Jan 2026 16:00:16 -0700 Subject: [PATCH 1/2] 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 --- src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b4d077b0..94cbdb01 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,7 +59,10 @@ pub trait RngCore: TryRngCore { fn fill_bytes(&mut self, dst: &mut [u8]); } -impl> RngCore for R { +impl RngCore for R +where + R: TryRngCore + ?Sized, +{ #[inline] fn next_u32(&mut self) -> u32 { match self.try_next_u32() { @@ -88,7 +91,7 @@ impl> RngCore for R { /// It is equivalent to the trait sum [RngCore] + [TryCryptoRng]. pub trait CryptoRng: TryCryptoRng {} -impl> CryptoRng for R {} +impl CryptoRng for R where R: TryCryptoRng + ?Sized {} /// Base trait for random number generators and random data sources /// From 99668776d670ed8d6a10c1a10849d8a760e86426 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Mon, 19 Jan 2026 17:22:40 -0700 Subject: [PATCH 2/2] Add `RngCore` to `CryptoRng`'s bounds --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 94cbdb01..22b601e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,7 +89,7 @@ where /// /// This is a convenient trait alias for [TryCryptoRng]. /// It is equivalent to the trait sum [RngCore] + [TryCryptoRng]. -pub trait CryptoRng: TryCryptoRng {} +pub trait CryptoRng: RngCore + TryCryptoRng {} impl CryptoRng for R where R: TryCryptoRng + ?Sized {}