[−][src]Struct caith::Roller
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
impl Roller
[src]
pub fn new(input: &str) -> Result<Self>
[src]
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.
pub fn roll(&self) -> Result<RollResult>
[src]
Evaluate and roll the dices with default Rng source (rand::thread_rng()
)
pub fn roll_with<RNG: Rng>(&self, rng: &mut RNG) -> Result<RollResult>
[src]
Evaluate and roll the dices with provided rng source
pub fn dices(&self) -> Result<Dices<'_>>
[src]
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<_>>());
pub fn as_str(&self) -> &str
[src]
Give back the query string
pub fn trim_reason(&mut self)
[src]
Removes the reason from the Roller
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Roller
[src]
impl Send for Roller
[src]
impl Sync for Roller
[src]
impl Unpin for Roller
[src]
impl UnwindSafe for Roller
[src]
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,