Trait xxcalc::calculator::Calculator
[−]
[src]
pub trait Calculator<T, P, E> where T: StringProcessor + Default, P: TokensProcessor + Default, E: TokensReducer + Default {
fn process(&self, line: &str) -> Result<Polynomial, CalculationError> { ... }
}
Calculator is the easiest way of evaluating string expressions
into a Polynomial
value.
A struct which is a calculator (implements this trait) can easily
perform evaluation using given StringProcessor
, TokensProcessor
and TokensReducer
.
Provided Methods
fn process(&self, line: &str) -> Result<Polynomial, CalculationError>
Takes string and evaluates it into a Polynomial.
This method creates a new instance of tokenizer, parser and evaluator for each execution. While it is easy to use, it is not the quickest way of evaluation when there are multiple expression.
Implementors
impl Calculator<Tokenizer, PolynomialParser, PolynomialEvaluator> for PolynomialCalculator
impl Calculator<Tokenizer, LinearSolverParser, LinearSolverEvaluator> for LinearSolver