Dice

Struct Dice 

Source
pub struct Dice<F, Rng>
where F: Faces + Index<usize>, Rng: CryptoRng,
{ /* private fields */ }
Expand description

Dice struct represents an implementation of dice, using a generic Faces collection and RNG.

Implementations§

Source§

impl<F, Rng> Dice<F, Rng>
where F: Faces + Index<usize>, Rng: CryptoRng + Rng,

Source

pub fn new(faces: F, rng: Rng) -> Self

Source§

impl<F, Rng> Dice<F, Rng>
where F: Faces + Index<usize>, F::Output: Copy, Rng: CryptoRng + Rng,

Source

pub fn roll(&mut self) -> <F as Index<usize>>::Output

Trait Implementations§

Source§

impl<F, Rng> Faces for Dice<F, Rng>
where F: Faces + Index<usize>, Rng: CryptoRng + Rng,

Source§

fn len(&self) -> usize

Returns the number of faces.
Source§

fn entropy_bits_per_face(&self) -> f64

Calculates the entropy in bits for one face.
Source§

fn entropy_bits(&self, n: usize) -> f64

Source§

fn needs_faces(&self, entropy_bits: f64) -> usize

Source§

fn needs_length_as_bytes(&self, entropy_bits: f64) -> usize

Auto Trait Implementations§

§

impl<F, Rng> Freeze for Dice<F, Rng>
where Rng: Freeze, F: Freeze,

§

impl<F, Rng> RefUnwindSafe for Dice<F, Rng>

§

impl<F, Rng> Send for Dice<F, Rng>
where Rng: Send, F: Send,

§

impl<F, Rng> Sync for Dice<F, Rng>
where Rng: Sync, F: Sync,

§

impl<F, Rng> Unpin for Dice<F, Rng>
where Rng: Unpin, F: Unpin,

§

impl<F, Rng> UnwindSafe for Dice<F, Rng>
where Rng: UnwindSafe, F: UnwindSafe,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V