Skip to main content

HashTableKeyable

Trait HashTableKeyable 

Source
pub trait HashTableKeyable<K: ?Sized> {
    type Key<'a>: Borrow<K>
       where Self: 'a;

    // Required method
    fn get_key(&self) -> Self::Key<'_>;
}
Expand description

Trait that types must implement to expose the key used to store them in a HashTable.

This is the Rust analog of the GetKey portion of C++’s fbl::DefaultKeyedObjectTraits. Keys are compared for equality using K: Eq (the analog of KeyTraits::EqualTo).

The key of an object must not change while the object is contained in a HashTable.

Required Associated Types§

Source

type Key<'a>: Borrow<K> where Self: 'a

The type of key yielded by get_key, borrowing K.

Implementations may return an owned/by-value key (e.g. u64) or a borrowed/by-reference key (e.g. &'a KeyStruct).

Required Methods§

Source

fn get_key(&self) -> Self::Key<'_>

Returns the key of this object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§