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 {
208
208
/// [`BlockRngCore`]: block::BlockRngCore
209
209
pub trait CryptoRng { }
210
210
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
+ /// ```
214
229
pub trait CryptoRngCore : RngCore {
215
230
/// Upcast to an [`RngCore`] trait object.
216
231
fn as_rngcore ( & mut self ) -> & mut dyn RngCore ;
You can’t perform that action at this time.
0 commit comments