Struct evalexpr::HashMapContext
source · pub struct HashMapContext { /* private fields */ }
Expand description
A context that stores its mappings in hash maps.
Value and function mappings are stored independently, meaning that there can be a function and a value with the same identifier.
This context is type-safe, meaning that an identifier that is assigned a value of some type once cannot be assigned a value of another type.
Implementations§
Trait Implementations§
source§impl Clone for HashMapContext
impl Clone for HashMapContext
source§fn clone(&self) -> HashMapContext
fn clone(&self) -> HashMapContext
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Context for HashMapContext
impl Context for HashMapContext
source§fn get_value(&self, identifier: &str) -> Option<&Value>
fn get_value(&self, identifier: &str) -> Option<&Value>
Returns the value that is linked to the given identifier.
source§fn call_function(
&self,
identifier: &str,
argument: &Value
) -> EvalexprResult<Value>
fn call_function( &self, identifier: &str, argument: &Value ) -> EvalexprResult<Value>
Calls the function that is linked to the given identifier with the given argument.
If no function with the given identifier is found, this method returns
EvalexprError::FunctionIdentifierNotFound
.source§fn are_builtin_functions_disabled(&self) -> bool
fn are_builtin_functions_disabled(&self) -> bool
Checks if builtin functions are disabled.
source§fn set_builtin_functions_disabled(
&mut self,
disabled: bool
) -> EvalexprResult<()>
fn set_builtin_functions_disabled( &mut self, disabled: bool ) -> EvalexprResult<()>
Disables builtin functions if
disabled
is true
, and enables them otherwise.
If the context does not support enabling or disabling builtin functions, an error is returned.source§impl ContextWithMutableFunctions for HashMapContext
impl ContextWithMutableFunctions for HashMapContext
source§fn set_function(
&mut self,
identifier: String,
function: Function
) -> EvalexprResult<()>
fn set_function( &mut self, identifier: String, function: Function ) -> EvalexprResult<()>
Sets the function with the given identifier to the given function.
source§impl Debug for HashMapContext
impl Debug for HashMapContext
source§impl Default for HashMapContext
impl Default for HashMapContext
source§fn default() -> HashMapContext
fn default() -> HashMapContext
Returns the “default value” for a type. Read more
source§impl IterateVariablesContext for HashMapContext
impl IterateVariablesContext for HashMapContext
§type VariableIterator<'a> = Map<Iter<'a, String, Value>, fn(_: (&String, &Value)) -> (String, Value)>
type VariableIterator<'a> = Map<Iter<'a, String, Value>, fn(_: (&String, &Value)) -> (String, Value)>
The iterator type for iterating over variable name-value pairs.
§type VariableNameIterator<'a> = Cloned<Keys<'a, String, Value>>
type VariableNameIterator<'a> = Cloned<Keys<'a, String, Value>>
The iterator type for iterating over variable names.
source§fn iter_variables(&self) -> Self::VariableIterator<'_>
fn iter_variables(&self) -> Self::VariableIterator<'_>
Returns an iterator over pairs of variable names and values.
source§fn iter_variable_names(&self) -> Self::VariableNameIterator<'_>
fn iter_variable_names(&self) -> Self::VariableNameIterator<'_>
Returns an iterator over variable names.
Auto Trait Implementations§
impl !RefUnwindSafe for HashMapContext
impl Send for HashMapContext
impl Sync for HashMapContext
impl Unpin for HashMapContext
impl !UnwindSafe for HashMapContext
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more