Struct budvm::HashMap

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

source

pub fn new() -> Self

Returns a new, empty hash map.

Equivalent to std::collections::HashMap::new().

source§

impl<State> HashMap<State>where State: BuildHasher,

source

pub fn len(&self) -> usize

Returns the number of items contained.

source

pub fn is_empty(&self) -> bool

Returns true if this map contains no items.

source

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.

source

pub fn get(&self, key: &Value) -> Option<Value>

Returns the value associated with key, if present.

source

pub fn remove(&self, key: &Value) -> Option<Value>

Removes the value associated with key, if present.

source

pub fn into_inner(self) -> BudMap<Value, Value, State>

Extracts the contained collection type.

Trait Implementations§

source§

impl<State> Clone for HashMap<State>where State: Clone + BuildHasher,

source§

fn clone(&self) -> Self

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<State> Debug for HashMap<State>where State: BuildHasher + Debug,

source§

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

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

impl Default for HashMap<RandomState>

source§

fn default() -> Self

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

impl<State> DynamicValue for HashMap<State>where State: BuildHasher + Debug + Clone + Send + Sync + 'static,

source§

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

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 more
source§

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>

Calls a function by name with args.
source§

fn to_source(&self) -> Option<String>

Returns this value as represented in source, if possible.
source§

fn as_i64(&self) -> Option<i64>

Returns this value as an i64, if possible. Read more
source§

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>

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 more
source§

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>

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>

Attempts to compute the result multiplying self and other. Read more
source§

fn checked_div( &self, other: &Value, is_reverse: bool ) -> Result<Option<Value>, FaultKind>

Attempts to compute the result dividing self and other. Read more
source§

fn hash<H>(&self, state: &mut H) -> boolwhere H: Hasher,

Hashes the contents of this value. Returns true if this operation is supported. Read more
source§

impl<'a> TryFrom<PoppedValues<'a>> for HashMap<RandomState>

§

type Error = FaultKind

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

fn try_from(values: PoppedValues<'a>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<State> RefUnwindSafe for HashMap<State>

§

impl<State> Send for HashMap<State>where State: Send,

§

impl<State> Sync for HashMap<State>where State: Send,

§

impl<State> Unpin for HashMap<State>where State: Unpin,

§

impl<State> UnwindSafe for HashMap<State>

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromStack for Twhere T: DynamicValue + Clone,

source§

fn from_value(value: Value) -> Result<T, FaultKind>

Returns an instance constructing from the stack.
source§

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

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.