Skip to main content

ExprDef

Struct ExprDef 

Source
pub struct ExprDef;
Expand description

Parses a RPN expression and saves it to a function variable.

§Syntax

Expressions are defined using Reverse Polish Notation. For example, 1 2 + -> 3.

Each operator or number (generally called a node) must be separated by at least one whitespace character. Also supported is the node $N, for input values, and #<ident>, which allows calling other expressions inside of an expression.

Calling an expression will pop its required arguments from the stack. For example, [expr.def/inc/1 +][expr.call/inc/5] -> 6.

§Supported Operators

  • **: Exponent
  • log: Log of arg 1 with base of arg 2
  • abs: Absolute value
  • <=>: Three-way comparison
  • !=: Not equal
  • ==: Equal
  • <=: Less or equal
  • >=: Greater or equal
  • <<: Left shift
  • >>: Logical right shift
  • >>>: Arithmetic right shift
  • <: Less
  • >: Greater
  • +: Add
  • -: Subtract
  • *: Multiply
  • /: Divide
  • %: Modulus
  • ~: Negate
  • ?: Ternary (if first argument is nonzero, choose first argument, otherwise choose second argument)
  • &: Bitwise AND
  • |: Bitwise OR
  • ^: Bitwise XOR
  • !: Bitwise NOT
  • sin: Sine
  • cos: Cosine
  • tan: Tangent
  • asin: Arcsine
  • acos: Arccosine
  • atan: Arctangent
  • real: Real component of complex number
  • imag: Imaginary component of complex number
  • arg: Argument of complex number

§Arguments

  1. The name to save the expression under. 2… The expression

Trait Implementations§

Source§

impl Clone for ExprDef

Source§

fn clone(&self) -> ExprDef

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 Macro for ExprDef

Source§

fn name(&self) -> &[u8]

The macro’s defined name.
Source§

fn description(&self) -> &str

The macro’s description.
Source§

fn eval<'arg, 'reg: 'arg, 'exec: 'reg>( &self, _x: &'exec Executor, v: &'reg mut VariableRegistry, _r: &mut Xoshiro128PlusPlus, args: &mut dyn Iterator<Item = &'arg [u8]>, ) -> Result<Cow<'static, [u8]>, MacroError>

Evaluates the macro.
Source§

fn clone(&self) -> Box<dyn Macro>

Clones this macro into a box;
Source§

fn source(&self) -> &[u8]

The macro’s source code.
Source§

impl Copy for ExprDef

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V