Skip to main content

StableArena

Struct StableArena 

Source
pub struct StableArena<Id: Identifier, T> { /* private fields */ }
Expand description

Stable logical IDs over compact, dense physical payload storage.

Implementations§

Source§

impl<Id: Identifier, T> StableArena<Id, T>

Source

pub fn push(&mut self, value: T) -> Id

Inserts value under a fresh, monotonic identifier.

Source

pub fn len(&self) -> usize

Returns the number of live payloads.

Source

pub fn issued_len(&self) -> usize

Returns the number of logical IDs issued, including removed IDs.

Source

pub fn capacity(&self) -> usize

Returns the payload capacity reserved by the dense value vector.

Source

pub fn structural_bytes(&self) -> usize

Returns bytes reserved by the arena’s three structural vectors.

Allocations owned by T itself are deliberately excluded.

Source

pub fn is_empty(&self) -> bool

Returns true when no live payload remains.

Source

pub fn shrink_to_fit(&mut self)

Releases structural capacity retained beyond the current live/issued lengths.

Identifiers, liveness, and dense physical order are unchanged; only allocator capacity is returned. Intended for explicit end-of-mutation boundaries — shrinking after every removal would reallocate on the next growth.

Source

pub fn contains(&self, id: Id) -> bool

Returns whether id currently names a live payload.

Source

pub fn get(&self, id: Id) -> Option<Identified<Id, &T>>

Returns the live payload identified by id, if any.

Source

pub fn get_mut(&mut self, id: Id) -> Option<Identified<Id, &mut T>>

Returns the live payload identified by id mutably, if any.

Source

pub fn remove(&mut self, id: Id) -> T

Removes and returns id’s payload while preserving every other ID.

§Panics

Panics when id is unknown or was already removed.

Source

pub fn iter(&self) -> Iter<'_, Id, T>

Iterates over live entries in dense physical order.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, Id, T>

Iterates mutably over live entries in dense physical order.

Trait Implementations§

Source§

impl<Id: Clone + Identifier, T: Clone> Clone for StableArena<Id, T>

Source§

fn clone(&self) -> StableArena<Id, T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Id: Identifier, T: Debug> Debug for StableArena<Id, T>

Source§

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

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

impl<Id: Identifier, T> Default for StableArena<Id, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, Id: Identifier, T: Deserialize<'de>> Deserialize<'de> for StableArena<Id, T>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<Id: Eq + Identifier, T: Eq> Eq for StableArena<Id, T>

Source§

impl<Id: Identifier, T> FromIterator<T> for StableArena<Id, T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<Id: Identifier, T> Index<Id> for StableArena<Id, T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, id: Id) -> &Self::Output

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

impl<Id: Identifier, T> IndexMut<Id> for StableArena<Id, T>

Source§

fn index_mut(&mut self, id: Id) -> &mut Self::Output

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

impl<'a, Id: Identifier, T> IntoIterator for &'a StableArena<Id, T>

Source§

type Item = Identified<Id, &'a T>

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Id, T>

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, Id: Identifier, T> IntoIterator for &'a mut StableArena<Id, T>

Source§

type Item = Identified<Id, &'a mut T>

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, Id, T>

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<Id: Identifier, T> IntoIterator for StableArena<Id, T>

Source§

type Item = Identified<Id, T>

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Id, T>

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<Id: PartialEq + Identifier, T: PartialEq> PartialEq for StableArena<Id, T>

Source§

fn eq(&self, other: &StableArena<Id, T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<Id: Identifier, T: Serialize> Serialize for StableArena<Id, T>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<Id: PartialEq + Identifier, T: PartialEq> StructuralPartialEq for StableArena<Id, T>

Auto Trait Implementations§

§

impl<Id, T> Freeze for StableArena<Id, T>
where Vec<T>: Freeze, Vec<Id>: Freeze,

§

impl<Id, T> RefUnwindSafe for StableArena<Id, T>

§

impl<Id, T> Send for StableArena<Id, T>
where Vec<T>: Send, Vec<Id>: Send,

§

impl<Id, T> Sync for StableArena<Id, T>
where Vec<T>: Sync, Vec<Id>: Sync,

§

impl<Id, T> Unpin for StableArena<Id, T>
where Vec<T>: Unpin, Vec<Id>: Unpin,

§

impl<Id, T> UnsafeUnpin for StableArena<Id, T>
where Vec<T>: UnsafeUnpin, Vec<Id>: UnsafeUnpin,

§

impl<Id, T> UnwindSafe for StableArena<Id, T>
where Vec<T>: UnwindSafe, Vec<Id>: 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.