Trait dicetest::Die[][src]

pub trait Die<T>: DieOnce<T> {
    fn roll(&self, fate: Fate<'_>) -> T;

    fn map<U, F>(self, f: F) -> MapDie<T, U, Self, F>
    where
        Self: Sized,
        F: Fn(T) -> U
, { ... }
fn flatten<U>(self) -> FlattenDie<U, T, Self>
    where
        Self: Sized,
        T: DieOnce<U>
, { ... }
fn flat_map<U, UD, F>(self, f: F) -> FlatMapDie<T, U, Self, UD, F>
    where
        Self: Sized,
        UD: DieOnce<U>,
        F: Fn(T) -> UD
, { ... }
fn boxed<'a>(self) -> BoxedDie<'a, T>
    where
        Self: Sized + 'a
, { ... }
fn rc<'a>(self) -> RcDie<'a, T>
    where
        Self: Sized + 'a
, { ... }
fn arc(self) -> ArcDie<T>
    where
        Self: Sized + 'static
, { ... } }
Expand description

Trait for generating pseudorandom values of type T.

The Die trait represents a subset of DieOnce. It mirrors all methods of DieOnce without the suffix _once. These methods must behave in the same way. For example an implementation of Die must produce the same value with its methods roll and roll_once if they are called with the same Fate.

Required methods

Generates a pseudorandom value.

The Fate is the only source of the randomness. Besides that, the generation is deterministic.

Provided methods

Creates a new Die by mapping the generated values of self.

The function f will be applied to the generated values of self. The results of the function are the generated values of the new Die.

Creates a new Die whose values are generated by the generated Dies of self.

Creates a new Die similar to map, except that the mapping produces DieOnces.

The function f will be applied to the generated values of self. The results of the function are DieOnces that generates the values for the new Die.

It is semantically equivalent to self.map(f).flatten().

Puts self behind a Box pointer.

Puts self behind an Rc pointer.

Puts self behind an Arc pointer.

Implementations on Foreign Types

Implementors