pub struct Expr<'a> {
pub id: ExprId,
pub arena: &'a RefCell<ExprArena>,
}Expand description
Lightweight handle to a node in an ExprArena.
Carries a borrow of the arena (wrapped in RefCell so operator overloads
can push new nodes during arithmetic). Expr is Copy, so users freely
reuse a variable handle in many constraints.
Fields§
§id: ExprId§arena: &'a RefCell<ExprArena>Implementations§
Source§impl<'a> Expr<'a>
impl<'a> Expr<'a>
pub fn new(id: ExprId, arena: &'a RefCell<ExprArena>) -> Self
pub fn constant(arena: &'a RefCell<ExprArena>, v: f64) -> Self
pub fn from_var(arena: &'a RefCell<ExprArena>, v: VarId) -> Self
Sourcepub fn var_id(self) -> Option<VarId>
pub fn var_id(self) -> Option<VarId>
If this handle is a bare variable, return its VarId.
None for compound expressions (sums, products, constants, …).
Sourcepub fn param_id(self) -> Option<ParamId>
pub fn param_id(self) -> Option<ParamId>
If this handle is a bare parameter, return its ParamId.
None for compound expressions.
pub fn pow(self, exponent: Self) -> Self
pub fn powi(self, n: i32) -> Self
pub fn powf(self, n: f64) -> Self
pub fn sin(self) -> Self
pub fn cos(self) -> Self
pub fn exp(self) -> Self
pub fn log(self) -> Self
pub fn abs(self) -> Self
Trait Implementations§
impl<'a> Copy for Expr<'a>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Expr<'a>
impl<'a> !Send for Expr<'a>
impl<'a> !Sync for Expr<'a>
impl<'a> !UnwindSafe for Expr<'a>
impl<'a> Freeze for Expr<'a>
impl<'a> Unpin for Expr<'a>
impl<'a> UnsafeUnpin for Expr<'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