rand_core

Trait CryptoRngCore

source
pub trait CryptoRngCore: CryptoRng + RngCore {
    // Required method
    fn as_rngcore(&mut self) -> &mut dyn RngCore ;
}
Expand description

An extension trait that is automatically implemented for any type implementing RngCore and CryptoRng.

It may be used as a trait object, and supports upcasting to RngCore via the CryptoRngCore::as_rngcore method.

§Example

use rand_core::CryptoRngCore;

#[allow(unused)]
fn make_token(rng: &mut dyn CryptoRngCore) -> [u8; 32] {
    let mut buf = [0u8; 32];
    rng.fill_bytes(&mut buf);
    buf
}

Required Methods§

source

fn as_rngcore(&mut self) -> &mut dyn RngCore

Upcast to an RngCore trait object.

Implementors§