Struct qoqo_calculator::Calculator[][src]

pub struct Calculator {
    pub variables: HashMap<String, f64>,
}

Struct for parsing string expressions to floats

Fields

variables: HashMap<String, f64>

HashMap of variables in current Calculator

Implementations

impl Calculator[src]

pub fn new() -> Self[src]

Create new Calculator.

pub fn set_variable(&mut self, name: &str, value: f64)[src]

Set variable for Calculator.

Arguments

  1. name - Name of the variable
  2. value - Float value of the variable

pub fn get_variable(&self, name: &str) -> Result<f64, CalculatorError>[src]

Get variable for Calculator.

Arguments

  1. name - Name of the variable

Returns

value - Result

pub fn parse_str(&mut self, expression: &str) -> Result<f64, CalculatorError>[src]

Parse a string expression.

Arguments

  1. expression - Expression that is parsed

pub fn parse_get(
    &mut self,
    parse_variable: CalculatorFloat
) -> Result<f64, CalculatorError>
[src]

Function parse_get

Parse a CalculatorFloat to float

Arguments

  1. parse_variable - Parsed string CalculatorFloat or returns float value

Trait Implementations

impl Clone for Calculator[src]

impl Debug for Calculator[src]

impl Default for Calculator[src]

Auto Trait Implementations

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.