Struct wasmtime_environ::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 T)

🔬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

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