[][src]Struct calculi::equation::Equation

pub struct Equation { /* fields omitted */ }

The equation struct containing the equation text and the parsed component.Component.

Various functions can be executed on this equation to solve it or it's variables.

Methods

impl Equation[src]

pub fn new<T: Into<String>>(text: T) -> Equation[src]

Creates a new equation from an equation in string form

Examples

let eq = calculi::Equation::new("a * sqrt(x + 1)");

pub fn solve_with<'a>(
    &self,
    vars_raw: impl IntoIterator<Item = (&'a str, f32)>
) -> Component
[src]

Get the output of an equation with the given variable definitions

Examples

let eq = calculi::Equation::new("a * sqrt(x + 1)");

assert_eq!(eq.solve_with(vec![("a", 2.0), ("x", 8.0)]).to_float().unwrap(), 6.0);

pub fn solve_for<'a>(
    &self,
    outcome: f32,
    vars: impl IntoIterator<Item = (&'a str, f32)>
) -> (Component, f32)
[src]

Attempt to solve equation that contains an unknown variable Returns left over outcome and expression if solving failed

Examples

let eq = calculi::Equation::new("a * sqrt(x + 1)");

let solved = eq.solve_for(9.0, vec![("x", 8.0)]);

assert_eq!(solved.0.to_string(), "a");
assert_eq!(solved.1, 3.0);

Trait Implementations

impl Debug for Equation[src]

Auto Trait Implementations

impl Send for Equation

impl Sync for Equation

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.