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

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

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<'a> IterateVariablesContext<'a> for HashMapContext

Source§

type VariableIterator = Map<Iter<'a, String, Value>, fn((&String, &Value)) -> (String, Value)>

The iterator type for iterating over variable name-value pairs.
Source§

type VariableNameIterator = Cloned<Keys<'a, String, Value>>

The iterator type for iterating over variable names.
Source§

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

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

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

Returns an iterator over variable names.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.