[−][src]Trait evalexpr::Context
A mutable context for an expression tree.
A context defines methods to retrieve values and functions for literals in an expression tree.
In addition, it also allows the manipulation of values and functions.
This crate implements two basic variants, the EmptyContext
, that returns None
for each identifier and cannot be manipulated, and the HashMapContext
, that stores its mappings in hash maps.
The HashMapContext is type-safe and returns an error if the user tries to assign a value of a different type than before to an identifier.
Required methods
fn get_value(&self, identifier: &str) -> Option<&Value>
Returns the value that is linked to the given identifier.
fn get_function(&self, identifier: &str) -> Option<&Function>
Returns the function that is linked to the given identifier.
Provided methods
fn set_value(
&mut self,
_identifier: String,
_value: Value
) -> EvalexprResult<()>
&mut self,
_identifier: String,
_value: Value
) -> EvalexprResult<()>
Links the given value to the given identifier.
fn set_function(
&mut self,
_identifier: String,
_function: Function
) -> EvalexprResult<()>
&mut self,
_identifier: String,
_function: Function
) -> EvalexprResult<()>
Links the given function to the given identifier.
Implementors
impl Context for EmptyContext
[src]
fn get_value(&self, _identifier: &str) -> Option<&Value>
[src]
fn get_function(&self, _identifier: &str) -> Option<&Function>
[src]
fn set_value(
&mut self,
_identifier: String,
_value: Value
) -> EvalexprResult<()>
[src]
&mut self,
_identifier: String,
_value: Value
) -> EvalexprResult<()>
fn set_function(
&mut self,
_identifier: String,
_function: Function
) -> EvalexprResult<()>
[src]
&mut self,
_identifier: String,
_function: Function
) -> EvalexprResult<()>
impl Context for HashMapContext
[src]
fn get_value(&self, identifier: &str) -> Option<&Value>
[src]
fn get_function(&self, identifier: &str) -> Option<&Function>
[src]
fn set_value(&mut self, identifier: String, value: Value) -> EvalexprResult<()>
[src]
fn set_function(
&mut self,
identifier: String,
function: Function
) -> EvalexprResult<()>
[src]
&mut self,
identifier: String,
function: Function
) -> EvalexprResult<()>