[−][src]Struct cute_dnd_dice::Roll
D&D Roll representation
Fields
num: u16
Number of dices
faces: NonZeroU16
Number of faces on dice
extra: Modifier
Bonus to roll
Implementations
impl Roll
[src]
pub const fn new(num: u16, faces: NonZeroU16, extra: Modifier) -> Self
[src]
pub fn from_str(text: &str) -> Result<Self, ParseError>
[src]
Attempts to parse Roll from string [num]d<faces> [+ <extra>]
pub fn min(&self) -> u16
[src]
Returns minimum possible value.
pub fn max(&self) -> u16
[src]
Returns maximum possible value.
pub fn roll_with(&self, fun: fn() -> u64) -> u16
[src]
Rolls using specified callable to generate random numbers.
fn my_random() -> u64 { 0xff } let roll = cute_dnd_dice::Roll::from_str("2d20+1").unwrap(); assert_eq!(roll.roll_with(my_random), 3);
pub fn roll(&self) -> u16
[src]
Calculates roll with default random source.
It provides decent uniform distribution.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,