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]

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()));

Casts the Id to an Id of a different type.

This is handy when using IdSlab to generate proxy Id-s for an IdMap.

Panics

None.

Example

let mut id_slab: IdSlab<()> = IdSlab::new();
let id: Id<u32> = id_slab.insert(()).cast();

Trait Implementations

impl<T> Debug for Id<T>
[src]

Formats the value using the given formatter. Read more

impl<T> Hash for Id<T>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<T> PartialOrd for Id<T>
[src]

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

impl<T> PartialEq for Id<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T> Ord for Id<T>
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl<T> Clone for Id<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T> Copy for Id<T>
[src]

impl<T> Eq for Id<T>
[src]

impl<T> Default for Id<T>
[src]

Returns the "default value" for a type. Read more

impl<T> Index<Id<T>> for IdSlab<T>
[src]

The returned type after indexing.

Performs the indexing (container[index]) operation.

impl<T> IndexMut<Id<T>> for IdSlab<T>
[src]

Performs the mutable indexing (container[index]) operation.

Auto Trait Implementations

impl<T> Send for Id<T> where
    T: Send

impl<T> Sync for Id<T> where
    T: Sync