Struct rolldice::Dice [] [src]

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



impl Dice


Create a Dict instance give 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 });


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


Formats the value using the given formatter.

impl PartialEq for Dice


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


This method tests for !=.

impl Eq for Dice