pub struct Context {
pub vars: HashMap<String, Value>,
pub now_serial: Option<f64>,
}Expand description
Holds the named variable bindings for a formula evaluation.
All keys are stored and looked up in uppercase, so variable names are
case-insensitive (A1, a1, and A1 all refer to the same binding).
Fields§
§vars: HashMap<String, Value>§now_serial: Option<f64>Pinned “now” for volatile date functions (NOW, TODAY), as a
local-time spreadsheet serial datetime (integer part = day serial,
fraction = time of day). None ⇒ the functions read the ambient
local clock. Set via crate::Engine::evaluate_at (P1.4, issue #526).
Implementations§
Source§impl Context
impl Context
Sourcepub fn new(vars: HashMap<String, Value>) -> Self
pub fn new(vars: HashMap<String, Value>) -> Self
Create a Context from a map of variable name → value.
Keys are normalised to uppercase on insertion.
Sourcepub fn get(&self, name: &str) -> Value
pub fn get(&self, name: &str) -> Value
Look up a variable by name (case-insensitive). Returns Value::Empty if not found.
Sourcepub fn lookup(&self, name: &str) -> Option<Value>
pub fn lookup(&self, name: &str) -> Option<Value>
Look up a binding by name (case-insensitive), distinguishing an absent
binding (None) from one explicitly bound to Value::Empty
(Some(Value::Empty)). Used by the evaluator to decide whether a
reference should fall through to the resolver.