pub struct HashMap<State = RandomState>(_)
where
State: BuildHasher;
Expand description
A wrapper for std::collections::HashMap<Value,Value>
that prevents using
a Value
that does not support hashing by returning an error.
This type uses a Mutex
for interior mutability.
Implementations§
source§impl HashMap<RandomState>
impl HashMap<RandomState>
sourcepub fn new() -> Self
pub fn new() -> Self
Returns a new, empty hash map.
Equivalent to std::collections::HashMap::new()
.
source§impl<State> HashMap<State>where
State: BuildHasher,
impl<State> HashMap<State>where State: BuildHasher,
sourcepub fn insert(&self, k: Value, v: Value) -> Result<Option<Value>, FaultKind>
pub fn insert(&self, k: Value, v: Value) -> Result<Option<Value>, FaultKind>
Inserts a key-value pair into the map.
Equivalent to std::collections::HashMap::insert()
, except this
function checks that key.implements_hash()
returns true. If it does
not, FaultKind::ValueCannotBeHashed
will be returned.
sourcepub fn get(&self, key: &Value) -> Option<Value>
pub fn get(&self, key: &Value) -> Option<Value>
Returns the value associated with key
, if present.
sourcepub fn remove(&self, key: &Value) -> Option<Value>
pub fn remove(&self, key: &Value) -> Option<Value>
Removes the value associated with key
, if present.
sourcepub fn into_inner(self) -> BudMap<Value, Value, State>
pub fn into_inner(self) -> BudMap<Value, Value, State>
Extracts the contained collection type.
Trait Implementations§
source§impl Default for HashMap<RandomState>
impl Default for HashMap<RandomState>
source§impl<State> DynamicValue for HashMap<State>where
State: BuildHasher + Debug + Clone + Send + Sync + 'static,
impl<State> DynamicValue for HashMap<State>where State: BuildHasher + Debug + Clone + Send + Sync + 'static,
source§fn is_truthy(&self) -> bool
fn is_truthy(&self) -> bool
Returns true if the value contained is truthy. See
Value::is_truthy()
for examples of what this means for primitive
types.source§fn kind(&self) -> Symbol
fn kind(&self) -> Symbol
Returns a unique string identifying this type. This returned string will
be wrapped in
ValueKind::Dynamic
when Value::kind()
is invoked
on a dynamic value. Read moresource§fn partial_eq(&self, other: &Value) -> Option<bool>
fn partial_eq(&self, other: &Value) -> Option<bool>
Returns true if self and other are considered equal. Returns false if
self and other are able to be compared but are not equal. Returns None
if the values are unable to be compared. Read more
source§fn call(
&self,
name: &Symbol,
args: &mut PoppedValues<'_>
) -> Result<Value, FaultKind>
fn call( &self, name: &Symbol, args: &mut PoppedValues<'_> ) -> Result<Value, FaultKind>
Calls a function by
name
with args
.source§fn to_source(&self) -> Option<String>
fn to_source(&self) -> Option<String>
Returns this value as represented in source, if possible.
source§fn convert(&self, kind: &Symbol) -> Option<Value>
fn convert(&self, kind: &Symbol) -> Option<Value>
Converts this value to the given kind, if possible. Read more
source§fn partial_cmp(&self, other: &Value) -> Option<Ordering>
fn partial_cmp(&self, other: &Value) -> Option<Ordering>
Returns the relative ordering of
self
and other
, if a comparison is
able to be made. If the types cannot be compared, this function should
return None. Read moresource§fn checked_add(
&self,
other: &Value,
is_reverse: bool
) -> Result<Option<Value>, FaultKind>
fn checked_add( &self, other: &Value, is_reverse: bool ) -> Result<Option<Value>, FaultKind>
Attempts to compute the result adding self and other. Read more
source§fn checked_sub(
&self,
other: &Value,
is_reverse: bool
) -> Result<Option<Value>, FaultKind>
fn checked_sub( &self, other: &Value, is_reverse: bool ) -> Result<Option<Value>, FaultKind>
Attempts to compute the result subtracting self and other. Read more
source§fn checked_mul(
&self,
other: &Value,
is_reverse: bool
) -> Result<Option<Value>, FaultKind>
fn checked_mul( &self, other: &Value, is_reverse: bool ) -> Result<Option<Value>, FaultKind>
Attempts to compute the result multiplying self and other. Read more