Struct caith::Roller

source ·
pub struct Roller(_);
Expand description

An object holding the query.

It has no advantage compare to free function that would take &str as parameter (like previous version) but it provides a stable API for the day pest can have a Send type as the parse result.

see Pest’s issue and Forum topic

Implementations

Store the input

As of version 2.0.0, it always returns Ok(Self).

This is to have a stable API for further optimization where the parsing is done here (so it can fail) and saved, see Roller documentation above.

Evaluate and roll the dices with default Rng source (rand::thread_rng())

Evaluate and roll the dices with provided rng source

Evaluate and roll the dice with provided dice roll source

Get an iterator on the dices in the expression

Examples
use caith::Roller;

let r = Roller::new("1d6 + 1d4 + 1d10 + 1d20").unwrap();
assert_eq!(vec!["1d6", "1d4", "1d10", "1d20"], r.dices().expect("Error on parse").collect::<Vec<_>>());

Give back the query string

Removes the reason from the Roller

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.