pub struct Index { /* private fields */ }
Expand description
An index (and generation) into an Arena
.
To get an Index
, insert an element into an Arena
, and the Index
for
that element will be returned.
Examples
use generational_arena::Arena;
let mut arena = Arena::new();
let idx = arena.insert(123);
assert_eq!(arena[idx], 123);
Implementations
sourceimpl Index
impl Index
sourcepub fn from_raw_parts(a: usize, b: u64) -> Index
pub fn from_raw_parts(a: usize, b: u64) -> Index
Create a new Index
from its raw parts.
The parts must have been returned from an earlier call to
into_raw_parts
.
Providing arbitrary values will lead to malformed indices and ultimately panics.
sourcepub fn into_raw_parts(self) -> (usize, u64)
pub fn into_raw_parts(self) -> (usize, u64)
Convert this Index
into its raw parts.
This niche method is useful for converting an Index
into another
identifier type. Usually, you should prefer a newtype wrapper around
Index
like pub struct MyIdentifier(Index);
. However, for external
types whose definition you can’t customize, but which you can construct
instances of, this method can be useful.
Trait Implementations
sourceimpl Ord for Index
impl Ord for Index
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Index> for Index
impl PartialOrd<Index> for Index
sourcefn partial_cmp(&self, other: &Index) -> Option<Ordering>
fn partial_cmp(&self, other: &Index) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Index
impl Eq for Index
impl StructuralEq for Index
impl StructuralPartialEq for Index
Auto Trait Implementations
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnwindSafe for Index
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more