pub struct Dispenser { /* private fields */ }Expand description
A struct that holds a hidden variable, dispenses Hands with a lock on a
state, and shuffles afterward.
Implementations§
Source§impl Dispenser
impl Dispenser
Sourcepub fn new(len: usize) -> Self
pub fn new(len: usize) -> Self
Creates a new Dispenser, initializing it with choices for a slice of a given
len.
Sourcepub fn make_hand<'h, T>(&mut self, deck: &'h [T]) -> Option<Hand<'h, T>>
pub fn make_hand<'h, T>(&mut self, deck: &'h [T]) -> Option<Hand<'h, T>>
Creates a Hand from deck and an internal variable, this shuffles the variable afterwards.
This makes first sure that all possible choices are possible for deck, it does this by
checking the length of deck, and effectively comparing it to the len given when the
Dispenser was created.
This function returns None when it’s possible that elements in deck cannot be chosen, or
there are more possible choices than that deck has. (deck.len() != len)
This function returns Some when checks pass, and all choices has a corresponding element
in deck.
Trait Implementations§
Auto Trait Implementations§
impl !Send for Dispenser
impl !Sync for Dispenser
impl Freeze for Dispenser
impl RefUnwindSafe for Dispenser
impl Unpin for Dispenser
impl UnsafeUnpin for Dispenser
impl UnwindSafe for Dispenser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more