pub struct Id<T> { /* fields omitted */ }
The Id
of an element of type T
as returned by IdSlab
insertions.
Id
-s are opaque, but Copy
, comparable and hashable. Think of an Id
as a safe *const T
which you can dereference if you have a reference to the originating IdSlab
.
Internally an Id
is implemented as an (index, tag)
pair. The index
points to a slot in
the IdSlab
, while the tag
allows disambiguating between values when a slot gets reused (a
matching tag is stored in the slot and is incremented every time a value is removed from that
slot).
Returns an invalid Id
(which will never be returned by a container).
None.
let id_slab: IdSlab<&'static str> = IdSlab::new();
assert!(!id_slab.contains(Id::invalid()));
Casts the Id
to an Id
of a different type.
This is handy when using IdSlab
to generate proxy Id
-s for an IdMap
.
None.
let mut id_slab: IdSlab<()> = IdSlab::new();
let id: Id<u32> = id_slab.insert(()).cast();
Formats the value using the given formatter. Read more
Feeds this value into the given [Hasher
]. Read more
Feeds a slice of this type into the given [Hasher
]. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the minimum of two values. Read more
Performs copy-assignment from source
. Read more
Returns the "default value" for a type. Read more
The returned type after indexing.
Performs the indexing (container[index]
) operation.
Performs the mutable indexing (container[index]
) operation.