Struct calc::Context[][src]

pub struct Context<N> {
    pub history: Vec<N>,
}

Calculation context.

Stores a history of calculated values, so that the history lookups (@) work properly. Also reifies the numeric type backing the calculations.

Fields

history: Vec<N>

Implementations

impl<N> Context<N> where
    N: Debug + Calcable,
    <N as Calcable>::Err: 'static, 
[src]

pub fn evaluate(&mut self, expr: &str) -> Result<N, Error<N>>[src]

Evaluate an expression in this context.

This both returns the calculated value and stores a copy in the context’s history.

impl<N> Context<N> where
    N: Debug + Calcable + Numeric,
    <N as Calcable>::Err: 'static, 
[src]

pub fn evaluate_annotated(&mut self, expr: &str) -> Result<String, Error<N>>[src]

Evaluate an annotated expression in this context.

Annotations can include output formatting directives. Therefore, the return value is a formatted String.

This also stores a copy in the context’s history.

Trait Implementations

impl<N: Default> Default for Context<N>[src]

Auto Trait Implementations

impl<N> RefUnwindSafe for Context<N> where
    N: RefUnwindSafe

impl<N> Send for Context<N> where
    N: Send

impl<N> Sync for Context<N> where
    N: Sync

impl<N> Unpin for Context<N> where
    N: Unpin

impl<N> UnwindSafe for Context<N> where
    N: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.