Struct idcontain::Id
[−]
[src]
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
.
Implementation
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).
Methods
impl<T> Id<T>
[src]
fn invalid() -> Self
[src]
Returns an invalid Id
(which will never be returned by a container).
Panics
None.
Example
let id_slab: IdSlab<&'static str> = IdSlab::new(); assert!(!id_slab.contains(Id::invalid()));
fn cast<U>(self) -> Id<U>
[src]
Trait Implementations
impl<T> Debug for Id<T>
[src]
fn fmt(&self, formatter: &mut Formatter) -> FmtResult
[src]
Formats the value using the given formatter.
impl<T> Hash for Id<T>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T> PartialOrd for Id<T>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T> PartialEq for Id<T>
[src]
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Self) -> bool
[src]
This method tests for !=
.
impl<T> Ord for Id<T>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
[src]
ord_max_min
)Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
[src]
ord_max_min
)Compares and returns the minimum of two values. Read more
impl<T> Clone for Id<T>
[src]
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more