KeyedRef

Trait KeyedRef 

Source
pub trait KeyedRef: Keyed {
    type KeyRef<'a>: Clone + Deref<Target = Self::Key>
       where Self: 'a;

    // Required method
    fn upcast_key_ref<'short, 'long: 'short>(
        r: Self::KeyRef<'long>,
    ) -> Self::KeyRef<'short>
       where Self: 'long;
}
Expand description

Abstract keyed collection whose key can be referenced.

Required Associated Types§

Source

type KeyRef<'a>: Clone + Deref<Target = Self::Key> where Self: 'a

Type of references to keys of the collection.

Required Methods§

Source

fn upcast_key_ref<'short, 'long: 'short>( r: Self::KeyRef<'long>, ) -> Self::KeyRef<'short>
where Self: 'long,

Changes a key reference into a shorter lived reference.

See the CollectionRef::upcast_item_ref function for more information. You can use the covariant_key_ref! macro to automatically implement this function.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<K, V> KeyedRef for BTreeMap<K, V>

Source§

type KeyRef<'a> = &'a K where Self: 'a

Source§

fn upcast_key_ref<'short, 'long: 'short>( r: Self::KeyRef<'long>, ) -> Self::KeyRef<'short>
where Self: 'long,

Source§

impl<K, V> KeyedRef for HashMap<K, V>

Source§

type KeyRef<'a> = &'a K where Self: 'a

Source§

fn upcast_key_ref<'short, 'long: 'short>( r: Self::KeyRef<'long>, ) -> Self::KeyRef<'short>
where Self: 'long,

Implementors§