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

A slice mapping K -> V allocating dense entity references.

The BoxedSlice data structure uses the dense index space to implement a map with a boxed slice.

Implementations§

source§

impl<K, V> BoxedSlice<K, V>where K: EntityRef,

source

pub unsafe fn from_raw(raw: *mut [V]) -> Self

Create a new slice from a raw pointer. A safer way to create slices is to use PrimaryMap::into_boxed_slice().

Safety

This relies on raw pointing to a valid slice of Vs.

source

pub fn is_valid(&self, k: K) -> bool

Check if k is a valid key in the map.

source

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

Get the element at k if it exists.

source

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

Get the element at k if it exists, mutable version.

source

pub fn is_empty(&self) -> bool

Is this map completely empty?

source

pub fn len(&self) -> usize

Get the total number of entity references created.

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 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 last(&self) -> Option<&V>

Returns the last element that was inserted in the map.

Trait Implementations§

source§

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

source§

fn clone(&self) -> BoxedSlice<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> Debug for BoxedSlice<K, V>where K: EntityRef + Debug,

source§

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

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

impl<K, V> Index<K> for BoxedSlice<K, V>where K: EntityRef,

Immutable indexing into a BoxedSlice. The indexed value must be in the map.

§

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 BoxedSlice<K, V>where K: EntityRef,

Mutable indexing into a BoxedSlice.

source§

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

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

impl<'a, K, V> IntoIterator for &'a BoxedSlice<K, V>where K: EntityRef,

§

type Item = (K, &'a V)

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, K, V>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, K, V> IntoIterator for &'a mut BoxedSlice<K, V>where K: EntityRef,

§

type Item = (K, &'a mut V)

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, K, V>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<K, V> RefUnwindSafe for BoxedSlice<K, V>where K: RefUnwindSafe, V: RefUnwindSafe,

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.