cassowary

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.

Fields§

§terms: Vec<Term>§constant: f64

Implementations§

Source§

impl Expression

Source

pub fn from_constant(v: f64) -> Expression

Constructs an expression of the form n, where n is a constant real number, not a variable.

Source

pub fn from_term(term: Term) -> Expression

Constructs an expression from a single term. Forms an expression of the form n x where n is the coefficient, and x is the variable.

Source

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

General constructor. Each Term in terms is part of the sum forming the expression, as well as constant.

Source

pub fn negate(&mut self)

Mutates this expression by multiplying it by minus one.

Trait Implementations§

Source§

impl Add<Expression> for Term

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, e: 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, e: 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, e: 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, e: 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, t: 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, v: 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, v: 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, v: 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, e: Expression) -> 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, r: WeightedRelation) -> PartialConstraint

Performs the | operation. Read more
Source§

impl Clone for Expression

Source§

fn clone(&self) -> Expression

Returns a copy 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, v: 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, v: f64) -> Expression

Performs the / operation. Read more
Source§

impl From<Term> for Expression

Source§

fn from(t: Term) -> Expression

Converts to this type from the input type.
Source§

impl From<Variable> for Expression

Source§

fn from(v: Variable) -> Expression

Converts to this type from the input type.
Source§

impl From<f64> for Expression

Source§

fn from(v: f64) -> Expression

Converts to this type from the input type.
Source§

impl Mul<Expression> for f32

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, e: 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, e: 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, v: 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, v: f64) -> Expression

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 Sub<Expression> for Term

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, e: 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, e: 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, e: 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, e: 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, t: 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, v: 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, v: 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, v: 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, e: Expression) -> Expression

Performs the - operation. Read more

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.