Function lib_dice::roll_from_str [] [src]

pub fn roll_from_str(cmd: &str) -> Result<i32, DiceFormatError>

Parse a dice roll from a sting in one of the following formats


let roll_1 = roll_from_str("1d8").unwrap();  // roll a single 8 sided dice
let roll_2 = roll_from_str("2d6 + 7").unwrap();  // roll 2 6 sided dice with a +7 bonus


A lib_dice::DiceFormatError will be thrown if the dice string is malformed or empty.