MapDie

Struct MapDie 

Source
pub struct MapDie<T, U, D, F> { /* private fields */ }
Expand description

Adapter for DieOnce::map_once and Die::map.

Implementations§

Source§

impl<T, U, D, F> MapDie<T, U, D, F>

Source

pub fn new(d: D, f: F) -> Self

Trait Implementations§

Source§

impl<T, U, D, F> Die<U> for MapDie<T, U, D, F>
where D: Die<T>, F: Fn(T) -> U,

Source§

fn roll(&self, fate: Fate<'_>) -> U

Generates a pseudorandom value. Read more
Source§

fn map<U, F>(self, f: F) -> MapDie<T, U, Self, F>
where Self: Sized, F: Fn(T) -> U,

Creates a new Die by mapping the generated values of self. Read more
Source§

fn flatten<U>(self) -> FlattenDie<U, T, Self>
where Self: Sized, T: DieOnce<U>,

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

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,

Creates a new Die similar to map, except that the mapping produces DieOnces. Read more
Source§

fn boxed<'a>(self) -> BoxedDie<'a, T>
where Self: Sized + 'a,

Puts self behind a Box pointer.
Source§

fn rc<'a>(self) -> RcDie<'a, T>
where Self: Sized + 'a,

Puts self behind an Rc pointer.
Source§

fn arc(self) -> ArcDie<T>
where Self: Sized + 'static,

Puts self behind an Arc pointer.
Source§

impl<T, U, D, F> DieOnce<U> for MapDie<T, U, D, F>
where D: DieOnce<T>, F: FnOnce(T) -> U,

Source§

fn roll_once(self, fate: Fate<'_>) -> U

Consumes the generator and generates a pseudorandom value. Read more
Source§

fn map_once<U, F>(self, f: F) -> MapDie<T, U, Self, F>
where Self: Sized, F: FnOnce(T) -> U,

Creates a new DieOnce by mapping the generated values of self. Read more
Source§

fn flatten_once<U>(self) -> FlattenDie<U, T, Self>
where Self: Sized, T: DieOnce<U>,

Creates a new DieOnce whose value is generated by the generated DieOnce of self.
Source§

fn flat_map_once<U, DU, F>(self, f: F) -> FlatMapDie<T, U, Self, DU, F>
where Self: Sized, DU: DieOnce<U>, F: FnOnce(T) -> DU,

Creates a new DieOnce similar to map_once, except that the mapping produces a DieOnce. Read more
Source§

fn boxed_once<'a>(self) -> BoxedDieOnce<'a, T>
where Self: Sized + 'a,

Puts self behind a Box pointer.

Auto Trait Implementations§

§

impl<T, U, D, F> Freeze for MapDie<T, U, D, F>
where D: Freeze, F: Freeze,

§

impl<T, U, D, F> RefUnwindSafe for MapDie<T, U, D, F>

§

impl<T, U, D, F> Send for MapDie<T, U, D, F>
where D: Send, F: Send, T: Send, U: Send,

§

impl<T, U, D, F> Sync for MapDie<T, U, D, F>
where D: Sync, F: Sync, T: Sync, U: Sync,

§

impl<T, U, D, F> Unpin for MapDie<T, U, D, F>
where D: Unpin, F: Unpin, T: Unpin, U: Unpin,

§

impl<T, U, D, F> UnwindSafe for MapDie<T, U, D, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.