wasmtime_environ

Struct SecondaryMap

Source
pub struct SecondaryMap<K, V>
where K: EntityRef, V: Clone,
{ /* private fields */ }
Expand description

A mapping K -> V for densely indexed entity references.

The SecondaryMap data structure uses the dense index space to implement a map with a vector. Unlike PrimaryMap, an SecondaryMap can’t be used to allocate entity references. It is used to associate secondary information with entities.

The map does not track if an entry for a key has been inserted or not. Instead it behaves as if all keys have a default entry from the beginning.

Implementations§

Source§

impl<K, V> SecondaryMap<K, V>
where K: EntityRef, V: Clone,

Shared SecondaryMap implementation for all value types.

Source

pub fn new() -> SecondaryMap<K, V>
where V: Default,

Create a new empty map.

Source

pub fn with_capacity(capacity: usize) -> SecondaryMap<K, V>
where V: Default,

Create a new, empty map with the specified capacity.

The map will be able to hold exactly capacity elements without reallocating.

Source

pub fn with_default(default: V) -> SecondaryMap<K, V>

Create a new empty map with a specified default value.

This constructor does not require V to implement Default.

Source

pub fn capacity(&self) -> usize

Returns the number of elements the map can hold without reallocating.

Source

pub fn get(&self, k: K) -> Option<&V>

Get the element at k if it exists.

Source

pub fn is_empty(&self) -> bool

Is this map completely empty?

Source

pub fn clear(&mut self)

Remove all entries from this map.

Source

pub fn iter(&self) -> Iter<'_, K, V>

Iterate over all the keys and values in this map.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, K, V>

Iterate over all the keys and values in this map, mutable edition.

Source

pub fn keys(&self) -> Keys<K>

Iterate over all the keys in this map.

Source

pub fn values(&self) -> Iter<'_, V>

Iterate over all the values in this map.

Source

pub fn values_mut(&mut self) -> IterMut<'_, V>

Iterate over all the values in this map, mutable edition.

Source

pub fn resize(&mut self, n: usize)

Resize the map to have n entries by adding default entries as needed.

Trait Implementations§

Source§

impl<K, V> Clone for SecondaryMap<K, V>
where K: Clone + EntityRef, V: Clone,

Source§

fn clone(&self) -> SecondaryMap<K, V>

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<K, V> Debug for SecondaryMap<K, V>
where K: Debug + EntityRef, V: Debug + Clone,

Source§

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

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

impl<K, V> Default for SecondaryMap<K, V>
where K: EntityRef, V: Clone + Default,

Source§

fn default() -> SecondaryMap<K, V>

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

impl<'de, K, V> Deserialize<'de> for SecondaryMap<K, V>
where K: EntityRef, V: Clone + Deserialize<'de>,

Source§

fn deserialize<D>( deserializer: D, ) -> Result<SecondaryMap<K, V>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<K, V> Hash for SecondaryMap<K, V>
where K: Hash + EntityRef, V: Hash + Clone,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<K, V> Index<K> for SecondaryMap<K, V>
where K: EntityRef, V: Clone,

Immutable indexing into an SecondaryMap.

All keys are permitted. Untouched entries have the default value.

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, k: K) -> &V

Performs the indexing (container[index]) operation. Read more
Source§

impl<K, V> IndexMut<K> for SecondaryMap<K, V>
where K: EntityRef, V: Clone,

Mutable indexing into an SecondaryMap.

The map grows as needed to accommodate new keys.

Source§

fn index_mut(&mut self, k: K) -> &mut V

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<K, V> PartialEq for SecondaryMap<K, V>
where K: EntityRef, V: Clone + PartialEq,

Source§

fn eq(&self, other: &SecondaryMap<K, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, V> Serialize for SecondaryMap<K, V>

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<K, V> Eq for SecondaryMap<K, V>
where K: EntityRef, V: Clone + PartialEq + Eq,

Auto Trait Implementations§

§

impl<K, V> Freeze for SecondaryMap<K, V>
where V: Freeze,

§

impl<K, V> RefUnwindSafe for SecondaryMap<K, V>

§

impl<K, V> Send for SecondaryMap<K, V>
where V: Send, K: Send,

§

impl<K, V> Sync for SecondaryMap<K, V>
where V: Sync, K: Sync,

§

impl<K, V> Unpin for SecondaryMap<K, V>
where V: Unpin, K: Unpin,

§

impl<K, V> UnwindSafe for SecondaryMap<K, V>
where V: UnwindSafe, K: UnwindSafe,

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,