Trait Entry

Source
pub trait Entry<'a>: RawEntry<'a> {
    // Required methods
    fn or_insert(self, value: Self::Value) -> &'a mut Self::Value;
    fn or_insert_with<F>(self, f: F) -> &'a mut Self::Value
       where F: FnOnce() -> Self::Value;
}
Expand description

The Entry trait extends the RawEntry trait to provide additional methods for

Required Methods§

Source

fn or_insert(self, value: Self::Value) -> &'a mut Self::Value

if the entry is vacant, insert the given value

Source

fn or_insert_with<F>(self, f: F) -> &'a mut Self::Value
where F: FnOnce() -> Self::Value,

if the entry does not exist, insert the value returned by the provided function and return a mutable reference to it.

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<'a, K, V> Entry<'a> for Entry<'a, K, V>
where K: Ord,

Source§

fn or_insert(self, default: Self::Value) -> &'a mut Self::Value

Source§

fn or_insert_with<F>(self, f: F) -> &'a mut Self::Value
where F: FnOnce() -> Self::Value,

Source§

impl<'a, K, V> Entry<'a> for Entry<'a, K, V>
where K: Eq + Hash,

Source§

fn or_insert(self, default: Self::Value) -> &'a mut Self::Value

Source§

fn or_insert_with<F>(self, f: F) -> &'a mut Self::Value
where F: FnOnce() -> Self::Value,

Implementors§