pub trait Random: Sized {
// Required method
fn try_random_from_rng<R: TryRng + ?Sized>(
rng: &mut R,
) -> Result<Self, R::Error>;
// Provided methods
fn random_from_rng<R: Rng + ?Sized>(rng: &mut R) -> Self { ... }
fn try_random() -> Result<Self, Error> { ... }
fn random() -> Self { ... }
}Expand description
Random number generation support.
Required Methods§
Provided Methods§
Sourcefn random_from_rng<R: Rng + ?Sized>(rng: &mut R) -> Self
fn random_from_rng<R: Rng + ?Sized>(rng: &mut R) -> Self
Generate a random value.
If rng is a CSRNG, the generation is cryptographically secure as well.
Sourcefn try_random() -> Result<Self, Error>
fn try_random() -> Result<Self, Error>
Randomly generate a value of this type using the system’s ambient cryptographically secure random number generator.
§Errors
Returns getrandom::Error in the event the system’s ambient RNG experiences an internal
failure.
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.
Implementors§
impl Random for Limb
impl<MOD, const LIMBS: usize> Random for ConstMontyForm<MOD, LIMBS>where
MOD: ConstMontyParams<LIMBS>,
Available on crate feature
rand_core only.impl<T> Random for NonZero<T>
Available on crate feature
rand_core only.impl<T: Random> Random for Wrapping<T>
Available on crate feature
rand_core only.impl<const LIMBS: usize> Random for Int<LIMBS>
impl<const LIMBS: usize> Random for Odd<Uint<LIMBS>>
Available on crate feature
rand_core only.