Struct slotmap::Key[][src]

pub struct Key { /* fields omitted */ }

Key used to access stored values in a slot map.

Do not use a key from one slot map in another. The behavior is safe but non-sensical (and might panic in case of out-of-bounds). Keys implement Ord so they can be used in e.g. BTreeMap but their order is arbitrary.

Methods

impl Key
[src]

Creates a new key that is always invalid and distinct from any non-null key. A null key can only be created through this method, or default initialization of Key.

A null key is always invalid, but an invalid key (that is, a key that has been removed from the slot map) does not become a null key. A null is safe to use with any safe method of any slot map instance.

Examples

let mut sm = SlotMap::<i32>::new();
let nk = Key::null();
assert!(nk.is_null());
assert_eq!(sm.get(nk), None);

Checks if a key is null. There is only a single null key, that is a.is_null() && b.is_null() implies a == b.

Examples

let a = Key::null();
let b = Key::default();
assert_eq!(a, b);

Trait Implementations

impl<T: Slottable> Index<Key> for SlotMap<T>
[src]

The returned type after indexing.

Performs the indexing (container[index]) operation.

impl<T: Slottable> IndexMut<Key> for SlotMap<T>
[src]

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

impl<T> Index<Key> for DenseSlotMap<T>
[src]

The returned type after indexing.

Performs the indexing (container[index]) operation.

impl<T> IndexMut<Key> for DenseSlotMap<T>
[src]

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

impl Debug for Key
[src]

Formats the value using the given formatter. Read more

impl Clone for Key
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for Key
[src]

impl PartialEq for Key
[src]

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

This method tests for !=.

impl Eq for Key
[src]

impl PartialOrd for Key
[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 Ord for Key
[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 Hash for Key
[src]

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

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

impl Default for Key
[src]

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

Auto Trait Implementations

impl Send for Key

impl Sync for Key