Skip to main content

SecondaryMap

Struct SecondaryMap 

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

Like cranelift_entity::SecondaryMap but all allocation is fallible.

Implementations§

Source§

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

Source

pub fn new() -> Self
where V: Default,

Source

pub fn with_capacity(capacity: usize) -> Result<Self, OutOfMemory>
where V: Default,

Source

pub fn with_default(default: V) -> Self

Source

pub fn capacity(&self) -> usize

Source

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

Source

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

Source

pub fn insert(&mut self, k: K, v: V) -> Result<Option<V>, OutOfMemory>

Source

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

Source

pub fn is_empty(&self) -> bool

Source

pub fn clear(&mut self)

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn resize(&mut self, n: usize) -> Result<(), OutOfMemory>

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

Trait Implementations§

Source§

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

Source§

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

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

Source§

type Output = V

The returned type after indexing.
Source§

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

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

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> 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, 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.