truecalc-core 3.2.0

Formula engine with exact Google Sheets semantics — stateless, embeddable evaluator
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Test helpers for truecalc-core integration tests.
use truecalc_core::{Engine, Value};
use std::collections::HashMap;

/// Convenience: evaluate a formula with no variables.
pub fn eval(formula: &str) -> Value {
    Engine::sheets().evaluate(formula, &HashMap::new())
}

/// Convenience: evaluate a formula with string-keyed variables.
pub fn eval_with(formula: &str, vars: impl IntoIterator<Item = (&'static str, Value)>) -> Value {
    let mut map = HashMap::new();
    for (k, v) in vars {
        map.insert(k.to_string(), v);
    }
    Engine::sheets().evaluate(formula, &map)
}