Struct wasmtime_environ::entity::PrimaryMap [−][src]
pub struct PrimaryMap<K, V> where
K: EntityRef, { /* fields omitted */ }
Expand description
A primary mapping K -> V
allocating dense entity references.
The PrimaryMap
data structure uses the dense index space to implement a map with a vector.
A primary map contains the main definition of an entity, and it can be used to allocate new
entity references with the push
method.
There should only be a single PrimaryMap
instance for a given EntityRef
type, otherwise
conflicting references will be created. Using unknown keys for indexing will cause a panic.
Note that PrimaryMap
doesn’t implement Deref
or DerefMut
, which would allow
&PrimaryMap<K, V>
to convert to &[V]
. One of the main advantages of PrimaryMap
is
that it only allows indexing with the distinct EntityRef
key type, so converting to a
plain slice would make it easier to use incorrectly. To make a slice of a PrimaryMap
, use
into_boxed_slice
.
Implementations
Create a new empty map.
Create a new empty map with the given capacity.
Get the element at k
if it exists, mutable version.
Iterate over all the values in this map, mutable edition.
Iterate over all the keys and values in this map, mutable edition.
Append v
to the mapping, assigning a new key which is returned.
Reserves capacity for at least additional
more elements to be inserted.
Reserves the minimum capacity for exactly additional
more elements to be inserted.
Shrinks the capacity of the PrimaryMap
as much as possible.
Consumes this PrimaryMap
and produces a BoxedSlice
.
Performs a binary search on the values with a key extraction function.
Assumes that the values are sorted by the key extracted by the function.
If the value is found then Ok(K)
is returned, containing the entity key
of the matching value.
If there are multiple matches, then any one of the matches could be returned.
If the value is not found then Err(K) is returned, containing the entity key where a matching element could be inserted while maintaining sorted order.
Trait Implementations
Returns the “default value” for a type. Read more
impl<'de, K, V> Deserialize<'de> for PrimaryMap<K, V> where
K: EntityRef,
V: Deserialize<'de>,
[src]
impl<'de, K, V> Deserialize<'de> for PrimaryMap<K, V> where
K: EntityRef,
V: Deserialize<'de>,
[src]pub fn deserialize<__D>(
__deserializer: __D
) -> Result<PrimaryMap<K, V>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<PrimaryMap<K, V>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
Creates a value from an iterator. Read more
Immutable indexing into an PrimaryMap
.
The indexed value must be in the map.
Mutable indexing into an PrimaryMap
.
impl<K, V> PartialEq<PrimaryMap<K, V>> for PrimaryMap<K, V> where
K: PartialEq<K> + EntityRef,
V: PartialEq<V>,
[src]
impl<K, V> PartialEq<PrimaryMap<K, V>> for PrimaryMap<K, V> where
K: PartialEq<K> + EntityRef,
V: PartialEq<V>,
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl<K, V> RefUnwindSafe for PrimaryMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for PrimaryMap<K, V> where
K: Send,
V: Send,
impl<K, V> Sync for PrimaryMap<K, V> where
K: Sync,
V: Sync,
impl<K, V> Unpin for PrimaryMap<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for PrimaryMap<K, V> where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.