[−][src]Struct calculi::equation::Equation
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]
&self,
vars_raw: impl IntoIterator<Item = (&'a str, f32)>
) -> Component
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]
&self,
outcome: f32,
vars: impl IntoIterator<Item = (&'a str, f32)>
) -> (Component, f32)
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
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,