Expression

Struct Expression 

Source
pub struct Expression {
    pub terms: Vec<Term>,
    pub constant: f64,
}
Expand description

An expression that can be the left hand or right hand side of a constraint equation.

It is a linear combination of variables, i.e., a sum of variables weighted by coefficients, plus an optional constant.

expression = term_1 + term_2 + ... + term_n + constant

Fields§

§terms: Vec<Term>

The terms in the expression.

§constant: f64

The constant in the expression.

Implementations§

Source§

impl Expression

Source

pub const fn new(terms: Vec<Term>, constant: f64) -> Expression

Create a new Expression.

expression = term_1 + term_2 + ... + term_n + constant
Source

pub const fn from_constant(constant: f64) -> Expression

Constructs an expression that represents a constant without any terms

expression = constant
Source

pub fn from_term(term: Term) -> Expression

Constructs an expression from a single term.

expression = term
Source

pub const fn from_terms(terms: Vec<Term>) -> Expression

Constructs an expression from a terms

expression = term_1 + term_2 + ... + term_n
Source

pub fn from_variable(variable: Variable) -> Expression

Constructs an expression from a variable

expression = variable

Trait Implementations§

Source§

impl Add<Expression> for Term

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<Expression> for Variable

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, expression: Expression) -> Expression

Performs the + operation. Read more
Source§

impl Add<Expression> for f32

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<Expression> for f64

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<Term> for Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Term) -> Expression

Performs the + operation. Read more
Source§

impl Add<Variable> for Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, variable: Variable) -> Expression

Performs the + operation. Read more
Source§

impl Add<f32> for Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f32) -> Expression

Performs the + operation. Read more
Source§

impl Add<f64> for Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add for Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign<Term> for Expression

Source§

fn add_assign(&mut self, rhs: Term)

Performs the += operation. Read more
Source§

impl AddAssign<Variable> for Expression

Source§

fn add_assign(&mut self, variable: Variable)

Performs the += operation. Read more
Source§

impl AddAssign<f32> for Expression

Source§

fn add_assign(&mut self, rhs: f32)

Performs the += operation. Read more
Source§

impl AddAssign<f64> for Expression

Source§

fn add_assign(&mut self, rhs: f64)

Performs the += operation. Read more
Source§

impl AddAssign for Expression

Source§

fn add_assign(&mut self, rhs: Expression)

Performs the += operation. Read more
Source§

impl BitOr<Expression> for PartialConstraint

Source§

type Output = Constraint

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Expression) -> Constraint

Performs the | operation. Read more
Source§

impl BitOr<WeightedRelation> for Expression

Source§

type Output = PartialConstraint

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: WeightedRelation) -> PartialConstraint

Performs the | operation. Read more
Source§

impl Clone for Expression

Source§

fn clone(&self) -> Expression

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Expression

Source§

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

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

impl Div<f32> for Expression

Source§

type Output = Expression

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Expression

Performs the / operation. Read more
Source§

impl Div<f64> for Expression

Source§

type Output = Expression

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl DivAssign<f32> for Expression

Source§

fn div_assign(&mut self, v: f32)

Performs the /= operation. Read more
Source§

impl DivAssign<f64> for Expression

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl From<Term> for Expression

Source§

fn from(term: Term) -> Expression

Converts to this type from the input type.
Source§

impl From<Variable> for Expression

Source§

fn from(variable: Variable) -> Expression

Converts to this type from the input type.
Source§

impl From<f64> for Expression

Source§

fn from(constant: f64) -> Expression

Converts to this type from the input type.
Source§

impl FromIterator<Term> for Expression

Source§

fn from_iter<I: IntoIterator<Item = Term>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl Mul<Expression> for f32

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<Expression> for f64

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<f32> for Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Expression

Performs the * operation. Read more
Source§

impl Mul<f64> for Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign<f32> for Expression

Source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
Source§

impl MulAssign<f64> for Expression

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl Neg for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn neg(self) -> Expression

Performs the unary - operation. Read more
Source§

impl PartialEq for Expression

Source§

fn eq(&self, other: &Expression) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub<Expression> for Term

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<Expression> for Variable

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, expression: Expression) -> Expression

Performs the - operation. Read more
Source§

impl Sub<Expression> for f32

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<Expression> for f64

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<Term> for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Term) -> Expression

Performs the - operation. Read more
Source§

impl Sub<Variable> for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, variable: Variable) -> Expression

Performs the - operation. Read more
Source§

impl Sub<f32> for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f32) -> Expression

Performs the - operation. Read more
Source§

impl Sub<f64> for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign<Term> for Expression

Source§

fn sub_assign(&mut self, rhs: Term)

Performs the -= operation. Read more
Source§

impl SubAssign<Variable> for Expression

Source§

fn sub_assign(&mut self, variable: Variable)

Performs the -= operation. Read more
Source§

impl SubAssign<f32> for Expression

Source§

fn sub_assign(&mut self, rhs: f32)

Performs the -= operation. Read more
Source§

impl SubAssign<f64> for Expression

Source§

fn sub_assign(&mut self, rhs: f64)

Performs the -= operation. Read more
Source§

impl SubAssign for Expression

Source§

fn sub_assign(&mut self, rhs: Expression)

Performs the -= operation. Read more
Source§

impl StructuralPartialEq for Expression

Auto Trait Implementations§

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.