ganit-core 0.4.1

Spreadsheet formula engine — parser and evaluator for Excel-compatible formulas
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Test helpers for ganit-core integration tests.
use ganit_core::{evaluate, Value};
use std::collections::HashMap;

/// Convenience: evaluate a formula with no variables.
pub fn eval(formula: &str) -> Value {
    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);
    }
    evaluate(formula, &map)
}