Skip to main content

Expr

Struct Expr 

Source
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>

Source

pub fn new(id: ExprId, arena: &'a RefCell<ExprArena>) -> Self

Source

pub fn constant(arena: &'a RefCell<ExprArena>, v: f64) -> Self

Source

pub fn from_var(arena: &'a RefCell<ExprArena>, v: VarId) -> Self

Source

pub fn var_id(self) -> Option<VarId>

If this handle is a bare variable, return its VarId. None for compound expressions (sums, products, constants, …).

Source

pub fn param_id(self) -> Option<ParamId>

If this handle is a bare parameter, return its ParamId. None for compound expressions.

Source

pub fn pow(self, exponent: Self) -> Self

Source

pub fn powi(self, n: i32) -> Self

Source

pub fn powf(self, n: f64) -> Self

Source

pub fn sin(self) -> Self

Source

pub fn cos(self) -> Self

Source

pub fn exp(self) -> Self

Source

pub fn log(self) -> Self

Source

pub fn abs(self) -> Self

Trait Implementations§

Source§

impl<'a> Add for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl<'a> Add<Expr<'a>> for f64

Source§

type Output = Expr<'a>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Expr<'a>) -> Expr<'a>

Performs the + operation. Read more
Source§

impl<'a> Add<Expr<'a>> for i32

Source§

type Output = Expr<'a>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Expr<'a>) -> Expr<'a>

Performs the + operation. Read more
Source§

impl<'a> Add<f64> for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Self

Performs the + operation. Read more
Source§

impl<'a> Add<i32> for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i32) -> Self

Performs the + operation. Read more
Source§

impl<'a> Clone for Expr<'a>

Source§

fn clone(&self) -> Expr<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Expr<'a>

Source§

impl Debug for Expr<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Div for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self

Performs the / operation. Read more
Source§

impl<'a> Div<Expr<'a>> for f64

Source§

type Output = Expr<'a>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Expr<'a>) -> Expr<'a>

Performs the / operation. Read more
Source§

impl<'a> Div<Expr<'a>> for i32

Source§

type Output = Expr<'a>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Expr<'a>) -> Expr<'a>

Performs the / operation. Read more
Source§

impl<'a> Div<f64> for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self

Performs the / operation. Read more
Source§

impl<'a> Div<i32> for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i32) -> Self

Performs the / operation. Read more
Source§

impl<'a> Mul for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
Source§

impl<'a> Mul<Expr<'a>> for f64

Source§

type Output = Expr<'a>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Expr<'a>) -> Expr<'a>

Performs the * operation. Read more
Source§

impl<'a> Mul<Expr<'a>> for i32

Source§

type Output = Expr<'a>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Expr<'a>) -> Expr<'a>

Performs the * operation. Read more
Source§

impl<'a> Mul<f64> for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self

Performs the * operation. Read more
Source§

impl<'a> Mul<i32> for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i32) -> Self

Performs the * operation. Read more
Source§

impl<'a> Neg for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<'a> Sub for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl<'a> Sub<Expr<'a>> for f64

Source§

type Output = Expr<'a>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Expr<'a>) -> Expr<'a>

Performs the - operation. Read more
Source§

impl<'a> Sub<Expr<'a>> for i32

Source§

type Output = Expr<'a>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Expr<'a>) -> Expr<'a>

Performs the - operation. Read more
Source§

impl<'a> Sub<f64> for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Self

Performs the - operation. Read more
Source§

impl<'a> Sub<i32> for Expr<'a>

Source§

type Output = Expr<'a>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i32) -> Self

Performs the - operation. Read more
Source§

impl<'a> Sum for Expr<'a>

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<'a, 'b> Sum<&'b Expr<'a>> for Expr<'a>

Source§

fn sum<I: Iterator<Item = &'b Expr<'a>>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.