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]

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

[src]

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]

[src]

Formats the value using the given formatter.

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

[src]

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

1.3.0
[src]

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

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

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[src]

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

[src]

This method tests for !=.

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

[src]

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

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the maximum of two values. Read more

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the minimum of two values. Read more

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

[src]

Returns a copy of the value. Read more

1.0.0
[src]

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]

[src]

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