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
**: Exponentlog: Log of arg 1 with base of arg 2abs: 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 NOTsin: Sinecos: Cosinetan: Tangentasin: Arcsineacos: Arccosineatan: Arctangentreal: Real component of complex numberimag: Imaginary component of complex numberarg: Argument of complex number
§Arguments
- The name to save the expression under. 2… The expression
Trait Implementations§
Source§impl Macro for ExprDef
impl Macro for ExprDef
Source§fn description(&self) -> &str
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>
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.
impl Copy for ExprDef
Auto Trait Implementations§
impl Freeze for ExprDef
impl RefUnwindSafe for ExprDef
impl Send for ExprDef
impl Sync for ExprDef
impl Unpin for ExprDef
impl UnsafeUnpin for ExprDef
impl UnwindSafe for ExprDef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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