File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,27 @@ use rand_core::{TryCryptoRng, TryRngCore};
1010/// This struct is also available as [`rand::rngs::OsRng`] when using [rand].
1111///
1212/// # Usage example
13+ ///
14+ /// `OsRng` implements [`TryRngCore`]:
1315/// ```
14- /// use getrandom::{rand_core::{ TryRngCore, RngCore} , OsRng};
16+ /// use getrandom::{rand_core::TryRngCore, OsRng};
1517///
1618/// let mut key = [0u8; 32];
1719/// OsRng.try_fill_bytes(&mut key).unwrap();
20+ /// ```
21+ ///
22+ /// Using it as an [`RngCore`] is possible using [`TryRngCore::unwrap_err`]:
23+ /// ```
24+ /// use getrandom::rand_core::{TryRngCore, RngCore};
25+ /// use getrandom::OsRng;
1826///
1927/// let mut rng = OsRng.unwrap_err();
2028/// let random_u64 = rng.next_u64();
2129/// ```
2230///
2331/// [rand]: https://crates.io/crates/rand
2432/// [`rand::rngs::OsRng`]: https://docs.rs/rand/latest/rand/rngs/struct.OsRng.html
33+ /// [`RngCore`]: rand_core::RngCore
2534#[ derive( Clone , Copy , Debug , Default ) ]
2635pub struct OsRng ;
2736
You can’t perform that action at this time.
0 commit comments