Struct rolldice::Dice [] [src]

pub struct Dice {
    pub number: u32,
    pub sides: u32,
}

Fields

Methods

impl Dice
[src]

[src]

Create a Dice instance given a standard dice format. Expected format is d where is the number of dice to roll and is the number of sides per dice rolled.

let result = rolldice::Dice::parse("4d6").unwrap();

assert_eq!(result, rolldice::Dice { number: 4, sides: 6 });

[src]

Generate a dice role from a Dice instance. Requires a random number generator from the "rand" crate to be passed in.

extern crate rand;
extern crate rolldice;

let dice = rolldice::Dice { number: 4, sides: 8 };
let mut rng = rand::thread_rng();

let result = dice.generate(&mut rng);

Trait Implementations

impl Debug for Dice
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for Dice
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for Dice
[src]