Enum Arithmetic

Source
pub enum Arithmetic<T> {
Show 32 variants Var(T), Literal(isize), Pow(Box<Arithmetic<T>>, Box<Arithmetic<T>>), PostIncr(T), PostDecr(T), PreIncr(T), PreDecr(T), UnaryPlus(Box<Arithmetic<T>>), UnaryMinus(Box<Arithmetic<T>>), LogicalNot(Box<Arithmetic<T>>), BitwiseNot(Box<Arithmetic<T>>), Mult(Box<Arithmetic<T>>, Box<Arithmetic<T>>), Div(Box<Arithmetic<T>>, Box<Arithmetic<T>>), Modulo(Box<Arithmetic<T>>, Box<Arithmetic<T>>), Add(Box<Arithmetic<T>>, Box<Arithmetic<T>>), Sub(Box<Arithmetic<T>>, Box<Arithmetic<T>>), ShiftLeft(Box<Arithmetic<T>>, Box<Arithmetic<T>>), ShiftRight(Box<Arithmetic<T>>, Box<Arithmetic<T>>), Less(Box<Arithmetic<T>>, Box<Arithmetic<T>>), LessEq(Box<Arithmetic<T>>, Box<Arithmetic<T>>), Great(Box<Arithmetic<T>>, Box<Arithmetic<T>>), GreatEq(Box<Arithmetic<T>>, Box<Arithmetic<T>>), Eq(Box<Arithmetic<T>>, Box<Arithmetic<T>>), NotEq(Box<Arithmetic<T>>, Box<Arithmetic<T>>), BitwiseAnd(Box<Arithmetic<T>>, Box<Arithmetic<T>>), BitwiseXor(Box<Arithmetic<T>>, Box<Arithmetic<T>>), BitwiseOr(Box<Arithmetic<T>>, Box<Arithmetic<T>>), LogicalAnd(Box<Arithmetic<T>>, Box<Arithmetic<T>>), LogicalOr(Box<Arithmetic<T>>, Box<Arithmetic<T>>), Ternary(Box<Arithmetic<T>>, Box<Arithmetic<T>>, Box<Arithmetic<T>>), Assign(T, Box<Arithmetic<T>>), Sequence(Vec<Arithmetic<T>>),
}
Expand description

Represents an expression within an arithmetic subsitution.

Generic over the representation of a variable name.

Variants§

§

Var(T)

The value of a variable, e.g. $var or var.

§

Literal(isize)

A numeric literal such as 42 or 0xdeadbeef.

§

Pow(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left ** right.

§

PostIncr(T)

Returns the current value of a variable, and then increments its value immediately after, e.g. var++

§

PostDecr(T)

Returns the current value of a variable, and then decrements its value immediately after, e.g. var--

§

PreIncr(T)

Increments the value of a variable and returns the new value, e.g. ++var.

§

PreDecr(T)

Decrements the value of a variable and returns the new value, e.g. --var.

§

UnaryPlus(Box<Arithmetic<T>>)

Ensures the sign of the underlying result is positive, e.g. +(1-2).

§

UnaryMinus(Box<Arithmetic<T>>)

Ensures the sign of the underlying result is negative, e.g. -(1+2).

§

LogicalNot(Box<Arithmetic<T>>)

Returns one if the underlying result is zero, or zero otherwise, e.g. !expr.

§

BitwiseNot(Box<Arithmetic<T>>)

Flips all bits from the underlying result, e.g. ~expr.

§

Mult(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left * right

§

Div(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left / right

§

Modulo(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left % right

§

Add(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left + right

§

Sub(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left - right

§

ShiftLeft(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left << right

§

ShiftRight(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left >> right

§

Less(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left < right

§

LessEq(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left <= right

§

Great(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left > right

§

GreatEq(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left >= right

§

Eq(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left == right

§

NotEq(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left != right

§

BitwiseAnd(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left & right

§

BitwiseXor(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left ^ right

§

BitwiseOr(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left | right

§

LogicalAnd(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left && right

§

LogicalOr(Box<Arithmetic<T>>, Box<Arithmetic<T>>)

left || right

§

Ternary(Box<Arithmetic<T>>, Box<Arithmetic<T>>, Box<Arithmetic<T>>)

first ? second : third

§

Assign(T, Box<Arithmetic<T>>)

Assigns the value of an underlying expression to a variable and returns the value, e.g. x = 5, or x += 2.

§

Sequence(Vec<Arithmetic<T>>)

expr[, expr[, ...]]

Trait Implementations§

Source§

impl<T: Clone> Clone for Arithmetic<T>

Source§

fn clone(&self) -> Arithmetic<T>

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<T: Debug> Debug for Arithmetic<T>

Source§

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

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

impl<T: PartialEq> PartialEq for Arithmetic<T>

Source§

fn eq(&self, other: &Arithmetic<T>) -> 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<T: Eq> Eq for Arithmetic<T>

Source§

impl<T> StructuralPartialEq for Arithmetic<T>

Auto Trait Implementations§

§

impl<T> Freeze for Arithmetic<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Arithmetic<T>
where T: RefUnwindSafe,

§

impl<T> Send for Arithmetic<T>
where T: Send,

§

impl<T> Sync for Arithmetic<T>
where T: Sync,

§

impl<T> Unpin for Arithmetic<T>
where T: Unpin,

§

impl<T> UnwindSafe for Arithmetic<T>
where T: UnwindSafe,

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.