[][src]Struct rcalc_lib::parse::CalcState

pub struct CalcState {
    pub has_alt: bool,
    pub alt_result: String,
    // some fields omitted
}

holds the current state of the engine, e.g list of all previously used variables

Fields

has_alt: boolalt_result: String

Methods

impl CalcState[src]

pub fn new() -> Self[src]

pub fn constant(&self, name: &str) -> Option<Value>[src]

Returns a constant value by its name. Name is caseinsensitive

pub fn variable(&self, name: &str) -> Option<Value>[src]

Returns a variable value by its name. Name is caseinsensitive

pub fn add_variable(&mut self, name: &str, val: Value)[src]

Creates a new variable or replace existing one with a new value. The function does not check variable's name for validity. In case of its name conflicts with existing function name, the variable will be inaccessible from expression evaluator

pub fn result(&self) -> Option<Value>[src]

Returns the result of the last successful evaluation

pub fn variable_name_validate(&self, name: &str) -> Result<(), &'static str>[src]

Check if variable name is valid:

  • name convention
  • does not conflict with any constant
  • does not conflist with any function
  • does not conflict with special variables, like ans

Trait Implementations

impl Default for CalcState[src]

Auto Trait Implementations

impl Send for CalcState

impl Sync for CalcState

Blanket Implementations

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.

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

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

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