Struct Index
pub struct Index(/* private fields */);Expand description
Implementations§
§impl Index
impl Index
pub const fn into_parts(self) -> (u32, Generation)
pub const fn into_parts(self) -> (u32, Generation)
Deconstruct this Index into its offset and its generation.
The offset is a position in a continuous array. When the array-cell at its offset is re-used after it has been removed, the generation for this cell is incremented.
The offset is a position in a continuous array.
§Example
let mut arena = Arena::new();
let index0 = arena.insert("test");
let index1 = arena.insert("test2");
assert_eq!((0, Generation::ONE), index0.into_parts());
assert_eq!((1, Generation::ONE), index1.into_parts());pub const fn offset(self) -> u32
pub const fn offset(self) -> u32
Returns the offset of this Index.
The offset is a position in a continuous array.
§Example
let mut arena = Arena::new();
let index0 = arena.insert("test");
let index1 = arena.insert("test2");
assert_eq!(0, index0.offset());
assert_eq!(1, index1.offset());pub const fn generation(self) -> Generation
pub const fn generation(self) -> Generation
Returns the generation of this Index.
When the array-cell at its offset is re-used after it has been removed, the generation for this cell is incremented.
§Example
let mut arena = Arena::new();
let index = arena.insert("test");
assert_eq!(Generation::ONE, index.generation());
arena.remove(index);
let index = arena.insert("test2");
assert_eq!(2, index.generation().get());Trait Implementations§
§impl Ord for Index
impl Ord for Index
§impl PartialOrd for Index
impl PartialOrd for Index
impl Copy for Index
impl Eq for Index
impl StructuralPartialEq for Index
Auto Trait Implementations§
impl Freeze for Index
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnwindSafe for Index
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more