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§

source§

impl HashMapContext

source

pub fn new() -> Self

Constructs a HashMapContext with no mappings.

Trait Implementations§

source§

impl Clone for HashMapContext

source§

fn clone(&self) -> HashMapContext

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Context for HashMapContext

source§

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>

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

Checks if builtin functions are disabled.
source§

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

source§

fn set_function( &mut self, identifier: String, function: Function ) -> EvalexprResult<()>

Sets the function with the given identifier to the given function.
source§

impl ContextWithMutableVariables for HashMapContext

source§

fn set_value(&mut self, identifier: String, value: Value) -> EvalexprResult<()>

Sets the variable with the given identifier to the given value.
source§

impl Debug for HashMapContext

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for HashMapContext

source§

fn default() -> HashMapContext

Returns the “default value” for a type. Read more
source§

impl IterateVariablesContext for HashMapContext

§

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>>

The iterator type for iterating over variable names.
source§

fn iter_variables(&self) -> Self::VariableIterator<'_>

Returns an iterator over pairs of variable names and values.
source§

fn iter_variable_names(&self) -> Self::VariableNameIterator<'_>

Returns an iterator over variable names.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.