Skip to main content

Random

Trait Random 

Source
pub trait Random: Sized {
    // Required method
    fn random(rng: impl CryptoRngCore) -> Self;

    // Provided methods
    fn random_n<Container: FromIterator<Self>>(
        rng: impl CryptoRngCore,
        size: usize,
    ) -> Container { ... }
    fn random_array<M: Positive>(rng: impl CryptoRngCore) -> HeapArray<Self, M> { ... }
}
Expand description

A trait for getting a random value for a type. Will be replaced by the random feature once it is included in std (https://github.com/rust-lang/rust/issues/130703).

Required Methods§

Source

fn random(rng: impl CryptoRngCore) -> Self

Provided Methods§

Source

fn random_n<Container: FromIterator<Self>>( rng: impl CryptoRngCore, size: usize, ) -> Container

Source

fn random_array<M: Positive>(rng: impl CryptoRngCore) -> HeapArray<Self, M>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Random for u8

Source§

fn random(rng: impl CryptoRngCore) -> Self

Source§

fn random_n<Container: FromIterator<Self>>( rng: impl CryptoRngCore, size: usize, ) -> Container

Source§

impl<T: Random> Random for Arc<T>

Source§

fn random(source: impl CryptoRngCore) -> Self

Implementors§