[−][src]Struct idcontain::Id
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]
pub 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()));
pub fn cast<U>(self) -> Id<U>
[src]
Trait Implementations
impl<T> Clone for Id<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Copy for Id<T>
[src]
impl<T> Default for Id<T>
[src]
impl<T> Eq for Id<T>
[src]
impl<T> Ord for Id<T>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T> PartialEq<Id<T>> for Id<T>
[src]
impl<T> PartialOrd<Id<T>> for Id<T>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T> Debug for Id<T>
[src]
impl<T> Index<Id<T>> for IdSlab<T>
[src]
impl<T> IndexMut<Id<T>> for IdSlab<T>
[src]
impl<T> Hash for Id<T>
[src]
Auto Trait Implementations
impl<T> Send for Id<T> where
T: Send,
T: Send,
impl<T> Sync for Id<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Id<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Id<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for Id<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,