pub enum Expression {
Lit(i64),
Var(Reference),
BinOp {
op: ArithOp,
lhs: Box<Expression>,
rhs: Box<Expression>,
},
Pow {
base: Box<Expression>,
exp: Box<Expression>,
},
FnCall {
name: Ident,
args: Vec<Expression>,
},
}Expand description
Expression in constraints — represents numeric formulas.
Rev.1: 5 variants replacing the old 4. Lit/Var/BinOp/Pow/FnCall.
Variants§
Lit(i64)
Integer literal: 1, 42, 1000000007.
Var(Reference)
Variable reference, such as N or A[i].
BinOp
Binary arithmetic: lhs op rhs.
Pow
Power: base^exp (e.g., 10^9, 2^30).
FnCall
Function call: min(a,b), max(a,b), abs(x), len(arr).
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn evaluate_constant(&self) -> Option<i64>
pub fn evaluate_constant(&self) -> Option<i64>
Evaluate to a constant if possible (no variable references).
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 PartialEq for Expression
impl PartialEq 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 UnsafeUnpin 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