Struct tyche::dice::roller::Iter

source ·
pub struct Iter<I: Iterator<Item = u8>>(/* private fields */);
Expand description

Generates rolls from an iterator of values. Mainly useful for testing purposes.

§Examples

use tyche::dice::{roller::{Iter as IterRoller, Roller}, Dice, DieRoll};

let mut roller = IterRoller::new(vec![1, 2, 3, 4, 10]);
let dice = Dice::new(5, 6);
assert_eq!(
	roller.roll(&dice, true)?.rolls,
	vec![DieRoll::new(1), DieRoll::new(2), DieRoll::new(3), DieRoll::new(4), DieRoll::new(10)]
);

Implementations§

source§

impl<I: Iterator<Item = u8>> Iter<I>

source

pub fn can_roll(&mut self) -> bool

Checks whether the iterator still has values available.

source

pub fn new(iter: impl IntoIterator<IntoIter = I>) -> Self

Creates a new roller that uses the given iterator to provide roll values.

Trait Implementations§

source§

impl<I: Clone + Iterator<Item = u8>> Clone for Iter<I>

source§

fn clone(&self) -> Iter<I>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<I: Debug + Iterator<Item = u8>> Debug for Iter<I>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<I: Iterator<Item = u8>> Roller for Iter<I>

source§

fn roll_die(&mut self, _sides: u8) -> DieRoll

Rolls a die with the value from the next iteration.

§Panics

If the iterator has finished, this will panic.

source§

fn roll<'d, 'r>( &mut self, dice: &'d Dice, apply_mods: bool ) -> Result<Rolled<'r>, Error>
where Self: Sized, 'd: 'r,

Rolls a set of dice and optionally applies all of its modifiers to the rolls. Read more

Auto Trait Implementations§

§

impl<I> RefUnwindSafe for Iter<I>
where I: RefUnwindSafe,

§

impl<I> Send for Iter<I>
where I: Send,

§

impl<I> Sync for Iter<I>
where I: Sync,

§

impl<I> Unpin for Iter<I>
where I: Unpin,

§

impl<I> UnwindSafe for Iter<I>
where I: 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.

§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a [MaybeRef].
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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

impl<T> MaybeSync for T

§

impl<'p, T> OrderedSeq<'p, T> for T
where T: Clone,