#[non_exhaustive]
pub enum Term {
Constant(i64),
DiceRoll(i64, i64),
KeepHigh(Id<Term>, i64),
KeepLow(Id<Term>, i64),
Explode(Id<Term>),
Add(Id<Term>, Id<Term>),
Subtract(Id<Term>, Id<Term>),
UnarySubtract(Id<Term>),
UnaryAdd(Id<Term>),
}
Expand description
An AST node. This represents an expression as a tree of nodes stored in an Arena
.
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.
Constant(i64)
DiceRoll(i64, i64)
A roll of the dice- what someone would do by shaking the set of dice in their hands and throwing it.
KeepHigh(Id<Term>, i64)
Filter the results of a dice roll, keeping only the highest N results in the total.
KeepLow(Id<Term>, i64)
Explode(Id<Term>)
Add(Id<Term>, Id<Term>)
Addition.
Subtract(Id<Term>, Id<Term>)
Subtraction.
UnarySubtract(Id<Term>)
Unary negation, flipping the sign of an integer.
UnaryAdd(Id<Term>)
A no-op, for symmetry with UnarySubtract
.
Implementations
sourceimpl Term
impl Term
pub fn unwrap_constant(self) -> i64
pub fn unwrap_dice_roll(self) -> (i64, i64)
pub fn unwrap_keep_high(self) -> (Id<Term>, i64)
pub fn unwrap_keep_low(self) -> (Id<Term>, i64)
pub fn unwrap_explode(self) -> Id<Term>
pub fn unwrap_add(self) -> (Id<Term>, Id<Term>)
pub fn unwrap_subtract(self) -> (Id<Term>, Id<Term>)
pub fn unwrap_unary_subtract(self) -> Id<Term>
pub fn unwrap_unary_add(self) -> Id<Term>
Trait Implementations
impl StructuralPartialEq for Term
Auto Trait Implementations
impl RefUnwindSafe for Term
impl Send for Term
impl Sync for Term
impl Unpin for Term
impl UnwindSafe for Term
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more