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]
impl Key
pub fn null() -> Self
[src]
pub fn null() -> Self
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);
pub fn is_null(self) -> bool
[src]
pub fn is_null(self) -> bool
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]
impl<T: Slottable> Index<Key> for SlotMap<T>
type Output = T
The returned type after indexing.
fn index(&self, key: Key) -> &T
[src]
fn index(&self, key: Key) -> &T
Performs the indexing (container[index]
) operation.
impl<T: Slottable> IndexMut<Key> for SlotMap<T>
[src]
impl<T: Slottable> IndexMut<Key> for SlotMap<T>
fn index_mut(&mut self, key: Key) -> &mut T
[src]
fn index_mut(&mut self, key: Key) -> &mut T
Performs the mutable indexing (container[index]
) operation.
impl<T> Index<Key> for DenseSlotMap<T>
[src]
impl<T> Index<Key> for DenseSlotMap<T>
type Output = T
The returned type after indexing.
fn index(&self, key: Key) -> &T
[src]
fn index(&self, key: Key) -> &T
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<Key> for DenseSlotMap<T>
[src]
impl<T> IndexMut<Key> for DenseSlotMap<T>
fn index_mut(&mut self, key: Key) -> &mut T
[src]
fn index_mut(&mut self, key: Key) -> &mut T
Performs the mutable indexing (container[index]
) operation.
impl Debug for Key
[src]
impl Debug for Key
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Key
[src]
impl Clone for Key
fn clone(&self) -> Key
[src]
fn clone(&self) -> Key
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Copy for Key
[src]
impl Copy for Key
impl PartialEq for Key
[src]
impl PartialEq for Key
fn eq(&self, other: &Key) -> bool
[src]
fn eq(&self, other: &Key) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Key) -> bool
[src]
fn ne(&self, other: &Key) -> bool
This method tests for !=
.
impl Eq for Key
[src]
impl Eq for Key
impl PartialOrd for Key
[src]
impl PartialOrd for Key
fn partial_cmp(&self, other: &Key) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Key) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Key) -> bool
[src]
fn lt(&self, other: &Key) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Key) -> bool
[src]
fn le(&self, other: &Key) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Key) -> bool
[src]
fn gt(&self, other: &Key) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Key) -> bool
[src]
fn ge(&self, other: &Key) -> bool
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]
impl Ord for Key
fn cmp(&self, other: &Key) -> Ordering
[src]
fn cmp(&self, other: &Key) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Hash for Key
[src]
impl Hash for Key
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
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]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Default for Key
[src]
impl Default for Key