Skip to content

Commit

Permalink
Add example to dice::roller::Iter
Browse files Browse the repository at this point in the history
  • Loading branch information
Gawdl3y committed Apr 22, 2024
1 parent c013b90 commit 53f0b40
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/dice/roller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ impl Roller for Max {
}

/// Generates rolls from an iterator of values. Mainly useful for testing purposes.
///
/// # Examples
/// ```
/// use dicey::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)]
/// );
/// # Ok::<(), dicey::dice::Error>(())
/// ```
#[derive(Debug, Clone)]
pub struct Iter<I: Iterator<Item = u8>>(Peekable<I>);

Expand Down

0 comments on commit 53f0b40

Please sign in to comment.