Function cpc::eval[][src]

pub fn eval(
    input: &str,
    allow_trailing_operators: bool,
    default_degree: Unit,
    verbose: bool
) -> Result<Number, String>
Expand description

Evaluates a string into a resulting Number.

Example:

use cpc::eval;
use cpc::units::Unit;
 
match eval("3m + 1cm", true, Unit::Celsius, false) {
    Ok(answer) => {
        // answer: Number { value: 301, unit: Unit::Centimeter }
        println!("Evaluated value: {} {:?}", answer.value, answer.unit)
    },
    Err(e) => {
        println!("{}", e)
    }
}