File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -208,9 +208,24 @@ pub trait RngCore {
208208/// [`BlockRngCore`]: block::BlockRngCore
209209pub trait CryptoRng { }
210210
211- /// An extension trait to support trait objects that implement [`RngCore`] and
212- /// [`CryptoRng`]. Upcasting to [`RngCore`] is supported via the
213- /// [`CryptoRngCore::as_rngcore`] method.
211+ /// An extension trait that is automatically implemented for any type
212+ /// implementing [`RngCore`] and [`CryptoRng`].
213+ ///
214+ /// It may be used as a trait object, and supports upcasting to [`RngCore`] via
215+ /// the [`CryptoRngCore::as_rngcore`] method.
216+ ///
217+ /// # Example
218+ ///
219+ /// ```
220+ /// use rand_core::CryptoRngCore;
221+ ///
222+ /// #[allow(unused)]
223+ /// fn make_token(rng: &mut dyn CryptoRngCore) -> [u8; 32] {
224+ /// let mut buf = [0u8; 32];
225+ /// rng.fill_bytes(&mut buf);
226+ /// buf
227+ /// }
228+ /// ```
214229pub trait CryptoRngCore : RngCore {
215230 /// Upcast to an [`RngCore`] trait object.
216231 fn as_rngcore ( & mut self ) -> & mut dyn RngCore ;
You can’t perform that action at this time.
0 commit comments