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
impl<K, V> PrimaryMap<K, V> where
K: EntityRef,
[src]
impl<K, V> PrimaryMap<K, V> where
K: EntityRef,
[src]pub fn new() -> PrimaryMap<K, V>
[src]
pub fn new() -> PrimaryMap<K, V>
[src]Create a new empty map.
pub fn with_capacity(capacity: usize) -> PrimaryMap<K, V>
[src]
pub fn with_capacity(capacity: usize) -> PrimaryMap<K, V>
[src]Create a new empty map with the given capacity.
pub fn get_mut(&mut self, k: K) -> Option<&mut V>
[src]
pub fn get_mut(&mut self, k: K) -> Option<&mut V>
[src]Get the element at k
if it exists, mutable version.
pub fn values_mut(&mut self) -> IterMut<'_, V>
[src]
pub fn values_mut(&mut self) -> IterMut<'_, V>
[src]Iterate over all the values in this map, mutable edition.
pub fn iter_mut(&mut self) -> IterMut<'_, K, V>
[src]
pub fn iter_mut(&mut self) -> IterMut<'_, K, V>
[src]Iterate over all the keys and values in this map, mutable edition.
pub fn push(&mut self, v: V) -> K
[src]
pub fn push(&mut self, v: V) -> K
[src]Append v
to the mapping, assigning a new key which is returned.
pub fn reserve(&mut self, additional: usize)
[src]
pub fn reserve(&mut self, additional: usize)
[src]Reserves capacity for at least additional
more elements to be inserted.
pub fn reserve_exact(&mut self, additional: usize)
[src]
pub fn reserve_exact(&mut self, additional: usize)
[src]Reserves the minimum capacity for exactly additional
more elements to be inserted.
pub fn shrink_to_fit(&mut self)
[src]
pub fn shrink_to_fit(&mut self)
[src]Shrinks the capacity of the PrimaryMap
as much as possible.
pub fn into_boxed_slice(self) -> BoxedSlice<K, V>
[src]
pub fn into_boxed_slice(self) -> BoxedSlice<K, V>
[src]Consumes this PrimaryMap
and produces a BoxedSlice
.
pub fn binary_search_values_by_key<'a, B, F>(
&'a self,
b: &B,
f: F
) -> Result<K, K> where
F: FnMut(&'a V) -> B,
B: Ord,
[src]
pub fn binary_search_values_by_key<'a, B, F>(
&'a self,
b: &B,
f: F
) -> Result<K, K> where
F: FnMut(&'a V) -> B,
B: Ord,
[src]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
impl<K, V> Clone for PrimaryMap<K, V> where
K: Clone + EntityRef,
V: Clone,
[src]
impl<K, V> Clone for PrimaryMap<K, V> where
K: Clone + EntityRef,
V: Clone,
[src]pub fn clone(&self) -> PrimaryMap<K, V>
[src]
pub fn clone(&self) -> PrimaryMap<K, V>
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl<K, V> Default for PrimaryMap<K, V> where
K: EntityRef,
[src]
impl<K, V> Default for PrimaryMap<K, V> where
K: EntityRef,
[src]pub fn default() -> PrimaryMap<K, V>
[src]
pub fn default() -> PrimaryMap<K, V>
[src]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
impl<K, V> FromIterator<V> for PrimaryMap<K, V> where
K: EntityRef,
[src]
impl<K, V> FromIterator<V> for PrimaryMap<K, V> where
K: EntityRef,
[src]pub fn from_iter<T>(iter: T) -> PrimaryMap<K, V> where
T: IntoIterator<Item = V>,
[src]
pub fn from_iter<T>(iter: T) -> PrimaryMap<K, V> where
T: IntoIterator<Item = V>,
[src]Creates a value from an iterator. Read more
impl<K, V> Index<K> for PrimaryMap<K, V> where
K: EntityRef,
[src]
impl<K, V> Index<K> for PrimaryMap<K, V> where
K: EntityRef,
[src]Immutable indexing into an PrimaryMap
.
The indexed value must be in the map.
impl<K, V> IndexMut<K> for PrimaryMap<K, V> where
K: EntityRef,
[src]
impl<K, V> IndexMut<K> for PrimaryMap<K, V> where
K: EntityRef,
[src]Mutable indexing into an PrimaryMap
.
impl<'a, K, V> IntoIterator for &'a mut PrimaryMap<K, V> where
K: EntityRef,
[src]
impl<'a, K, V> IntoIterator for &'a mut PrimaryMap<K, V> where
K: EntityRef,
[src]impl<'a, K, V> IntoIterator for &'a PrimaryMap<K, V> where
K: EntityRef,
[src]
impl<'a, K, V> IntoIterator for &'a PrimaryMap<K, V> where
K: EntityRef,
[src]impl<K, V> IntoIterator for PrimaryMap<K, V> where
K: EntityRef,
[src]
impl<K, V> IntoIterator for PrimaryMap<K, V> where
K: EntityRef,
[src]type IntoIter = IntoIter<K, V>
type IntoIter = IntoIter<K, V>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> <PrimaryMap<K, V> as IntoIterator>::IntoIter
[src]
pub fn into_iter(self) -> <PrimaryMap<K, V> as IntoIterator>::IntoIter
[src]Creates an iterator from a value. Read more
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]pub fn eq(&self, other: &PrimaryMap<K, V>) -> bool
[src]
pub fn eq(&self, other: &PrimaryMap<K, V>) -> bool
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
pub fn ne(&self, other: &PrimaryMap<K, V>) -> bool
[src]
pub fn ne(&self, other: &PrimaryMap<K, V>) -> bool
[src]This method tests for !=
.
impl<K, V> Serialize for PrimaryMap<K, V> where
K: EntityRef,
V: Serialize,
[src]
impl<K, V> Serialize for PrimaryMap<K, V> where
K: EntityRef,
V: Serialize,
[src]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
impl<K, V> Eq for PrimaryMap<K, V> where
K: Eq + EntityRef,
V: Eq,
[src]
K: Eq + EntityRef,
V: Eq,
impl<K, V> StructuralEq for PrimaryMap<K, V> where
K: EntityRef,
[src]
K: EntityRef,
impl<K, V> StructuralPartialEq for PrimaryMap<K, V> where
K: EntityRef,
[src]
K: EntityRef,
Auto Trait Implementations
impl<K, V> RefUnwindSafe for PrimaryMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for PrimaryMap<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for PrimaryMap<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
impl<K, V> Unpin for PrimaryMap<K, V> where
K: Unpin,
V: Unpin,
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for PrimaryMap<K, V> where
K: UnwindSafe,
V: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]pub fn equivalent(&self, key: &K) -> bool
[src]
pub fn equivalent(&self, key: &K) -> bool
[src]Compare self to key
and return true
if they are equal.
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,