ToRandom

Trait ToRandom 

Source
pub trait ToRandom: Sized {
    // Required method
    fn random<R: Rng + ?Sized>(rng: &mut R) -> Self;

    // Provided methods
    fn get_random<R: Rng + ?Sized>(&self, rng: &mut R) -> Self { ... }
    fn switch_to_random<R: Rng + ?Sized>(&mut self, rng: &mut R) { ... }
}
Expand description

Trait for enums that can get a random variant.

Required Methods§

Source

fn random<R: Rng + ?Sized>(rng: &mut R) -> Self

Gets a random variant.

Provided Methods§

Source

fn get_random<R: Rng + ?Sized>(&self, rng: &mut R) -> Self

Gets a random variant.

Source

fn switch_to_random<R: Rng + ?Sized>(&mut self, rng: &mut R)

Switches to a random variant.

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§