Struct mexprp::Expression
source · Expand description
The main Expression struct. Contains the string that was originally requested to be parsed, the context the Expression was parsed with, and the Term the raw form was parsed as. For just the parsed version of the expression, use the Term enum.
Fields§
§string: String
The original string passed into this expression
ctx: Context<N>
Context the expression was parsed with
term: Term<N>
The term this string has been parsed as
Implementations§
source§impl<N: Num + 'static> Expression<N>
impl<N: Num + 'static> Expression<N>
sourcepub fn parse(raw: &str) -> Result<Self, ParseError>
pub fn parse(raw: &str) -> Result<Self, ParseError>
Parse a string into an expression
sourcepub fn parse_ctx(raw: &str, ctx: Context<N>) -> Result<Self, ParseError>
pub fn parse_ctx(raw: &str, ctx: Context<N>) -> Result<Self, ParseError>
Parse a string into an expression with the given context
sourcepub fn eval(&self) -> Calculation<N>
pub fn eval(&self) -> Calculation<N>
Evaluate the expression
sourcepub fn eval_ctx(&self, ctx: &Context<N>) -> Calculation<N>
pub fn eval_ctx(&self, ctx: &Context<N>) -> Calculation<N>
Evaluate the expression with the given context
Trait Implementations§
source§impl<N: Clone + Num> Clone for Expression<N>
impl<N: Clone + Num> Clone for Expression<N>
source§fn clone(&self) -> Expression<N>
fn clone(&self) -> Expression<N>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<N: Num> Display for Expression<N>
impl<N: Num> Display for Expression<N>
Auto Trait Implementations§
impl<N> !RefUnwindSafe for Expression<N>
impl<N> !Send for Expression<N>
impl<N> !Sync for Expression<N>
impl<N> Unpin for Expression<N>where
N: Unpin,
impl<N> !UnwindSafe for Expression<N>
Blanket Implementations§
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.