pub enum Expression {
Expression(Box<Self>),
Macro(ExpressionMacroInvocation),
Terminal(Terminal),
Plus(Box<Self>, Box<Self>),
Minus(Box<Self>, Box<Self>),
Times(Box<Self>, Box<Self>),
Divide(Box<Self>, Box<Self>),
}Expand description
A mathematical expression.
Variants§
Expression(Box<Self>)
A mathematical expression.
Macro(ExpressionMacroInvocation)
An expression macro invocation.
Terminal(Terminal)
A terminal value.
Plus(Box<Self>, Box<Self>)
An addition operation.
Minus(Box<Self>, Box<Self>)
A subtraction operation.
Times(Box<Self>, Box<Self>)
A multiplication operation.
Divide(Box<Self>, Box<Self>)
A division operation.
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn eval_with_context(&self, ctx: Context<'_>) -> Result<BigInt, Error>
pub fn eval_with_context(&self, ctx: Context<'_>) -> Result<BigInt, Error>
Evaluates the expression given a certain Context.
Sourcepub fn labels(
&self,
macros: &HashMap<String, MacroDefinition>,
) -> Result<Vec<String>, Error>
pub fn labels( &self, macros: &HashMap<String, MacroDefinition>, ) -> Result<Vec<String>, Error>
Returns a list of all labels used in the expression.
Sourcepub fn replace_label(&mut self, old: &str, new: &str)
pub fn replace_label(&mut self, old: &str, new: &str)
Replaces all instances of old with new in the expression.
Sourcepub fn fill_variable(&mut self, var: &str, expr: &Expression)
pub fn fill_variable(&mut self, var: &str, expr: &Expression)
Replaces all instances of var with expr in the expression.
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Expression
impl Debug for Expression
Source§impl Display for Expression
impl Display for Expression
Source§impl From<BigInt> for Expression
impl From<BigInt> for Expression
Source§impl From<Expression> for Imm
impl From<Expression> for Imm
Source§fn from(tree: Expression) -> Self
fn from(tree: Expression) -> Self
Converts to this type from the input type.
Source§impl From<Terminal> for Expression
impl From<Terminal> for Expression
Source§impl Hash for Expression
impl Hash for Expression
Source§impl Ord for Expression
impl Ord for Expression
Source§fn cmp(&self, other: &Expression) -> Ordering
fn cmp(&self, other: &Expression) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for Expression
impl PartialEq for Expression
Source§impl PartialOrd for Expression
impl PartialOrd for Expression
impl Eq for Expression
impl StructuralPartialEq for Expression
Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnwindSafe for Expression
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