diff --git a/rapidrand/src/lib.rs b/rapidrand/src/lib.rs index edf1f50..fb377f8 100644 --- a/rapidrand/src/lib.rs +++ b/rapidrand/src/lib.rs @@ -7,7 +7,7 @@ #![deny(unused_must_use)] #[cfg(feature = "rand")] -use rand_core::{SeedableRng, TryRng, utils::fill_bytes_via_next_word}; +use rand_core::{Rng, SeedableRng, TryRng, utils::fill_bytes_via_next_word}; /// Rapidhash V1 secret[0]. /// @@ -171,4 +171,17 @@ impl SeedableRng for RapidRng { state: rapidrng(&mut state), } } + + fn from_rng(rng: &mut R) -> Self { + Self { + state: rng.next_u64(), + } + } + + fn try_from_rng(rng: &mut R) -> Result { + match rng.try_next_u64() { + Ok(state) => Ok(Self { state }), + Err(e) => Err(e), + } + } }