#[non_exhaustive]pub enum Evaled<'a> {
Num(i32),
Dice(Rolled<'a>),
Neg(Box<Self>),
Add(Box<Self>, Box<Self>),
Sub(Box<Self>, Box<Self>),
Mul(Box<Self>, Box<Self>),
DivDown(Box<Self>, Box<Self>),
DivUp(Box<Self>, Box<Self>),
}
Expand description
Tree structure of individual elements of an evaluated mathematical dice expression
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Num(i32)
Standalone integer
Dice(Rolled<'a>)
Rolled dice
Neg(Box<Self>)
Negation of an expression (makes the result of it negative)
Add(Box<Self>, Box<Self>)
Sum of two expressions
Sub(Box<Self>, Box<Self>)
Difference of two expressions
Mul(Box<Self>, Box<Self>)
Product of two expressions
DivDown(Box<Self>, Box<Self>)
Integer quotient of two expressions (rounded down)
DivUp(Box<Self>, Box<Self>)
Integer quotient of two expressions (rounded up)
Implementations§
source§impl Evaled<'_>
impl Evaled<'_>
sourcepub fn calc(&self) -> Result<i32, CalcError>
pub fn calc(&self) -> Result<i32, CalcError>
Calculates the final result of the evaluated expression and all of its children (if any).
§Errors
If there is an integer overflow or division error, or an error calculating the total of a set of dice rolls,an error variant will be returned.
sourcepub fn into_owned(self) -> Evaled<'static>
pub fn into_owned(self) -> Evaled<'static>
Moves all of self’s owned data into a new instance and clones any unowned data in order to create a 'static
instance of self.
Trait Implementations§
source§impl Describe for Evaled<'_>
impl Describe for Evaled<'_>
source§fn describe(&self, list_limit: Option<usize>) -> String
fn describe(&self, list_limit: Option<usize>) -> String
Builds a detailed expression string with additional information about non-deterministic elements.
Any elements of the expression that can have a different result between multiple evaluations or multiple results
should list all of the specific individual results that occurred (ideally, up to
list_limit
of them).source§impl HasOpType for Evaled<'_>
impl HasOpType for Evaled<'_>
source§fn is_additive(&self) -> bool
fn is_additive(&self) -> bool
Checks whether this expression is an additive operation.
source§fn is_multiplicative(&self) -> bool
fn is_multiplicative(&self) -> bool
Checks whether this expression is a multiplicative operation.
source§impl<'a> PartialEq for Evaled<'a>
impl<'a> PartialEq for Evaled<'a>
impl<'a> Eq for Evaled<'a>
impl<'a> StructuralPartialEq for Evaled<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Evaled<'a>
impl<'a> Send for Evaled<'a>
impl<'a> Sync for Evaled<'a>
impl<'a> Unpin for Evaled<'a>
impl<'a> UnwindSafe for Evaled<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
An iterator over the items within this container, by reference.
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
Check whether an item is contained within this sequence.
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
Convert an item of the sequence into a [
MaybeRef
].