value_trait::prelude

Trait ObjectMut

source
pub trait ObjectMut {
    type Key: ?Sized;
    type Element;

    // Required methods
    fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut Self::Element>
       where Self::Key: Borrow<Q>,
             Q: ?Sized + Hash + Eq + Ord;
    fn insert<K, V>(&mut self, k: K, v: V) -> Option<Self::Element>
       where Self::Key: From<K> + Hash + Eq,
             V: Into<Self::Element>;
    fn remove<Q>(&mut self, k: &Q) -> Option<Self::Element>
       where Self::Key: Borrow<Q>,
             Q: ?Sized + Hash + Eq + Ord;
}
Expand description

A mutable value Object

Required Associated Types§

source

type Key: ?Sized

The key in the objects

source

type Element

The values in the object

Required Methods§

source

fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut Self::Element>
where Self::Key: Borrow<Q>, Q: ?Sized + Hash + Eq + Ord,

Gets the value of a key as a mutable reference.

source

fn insert<K, V>(&mut self, k: K, v: V) -> Option<Self::Element>
where Self::Key: From<K> + Hash + Eq, V: Into<Self::Element>,

Inserts a value

source

fn remove<Q>(&mut self, k: &Q) -> Option<Self::Element>
where Self::Key: Borrow<Q>, Q: ?Sized + Hash + Eq + Ord,

Removes a value from the object

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<MapK, MapE, S> ObjectMut for HashMap<MapK, MapE, S>
where MapK: Hash + Eq, S: BuildHasher + Default,

source§

type Key = MapK

source§

type Element = MapE

source§

fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut Self::Element>
where Self::Key: Borrow<Q>, Q: ?Sized + Hash + Eq + Ord,

source§

fn insert<K, V>(&mut self, k: K, v: V) -> Option<Self::Element>
where K: Into<Self::Key>, V: Into<Self::Element>, Self::Key: Hash + Eq,

source§

fn remove<Q>(&mut self, k: &Q) -> Option<Self::Element>
where Self::Key: Borrow<Q>, Q: ?Sized + Hash + Eq + Ord,

source§

impl<MapK, MapE, S: BuildHasher> ObjectMut for HashMap<MapK, MapE, S>
where MapK: Hash + Eq,

source§

type Key = MapK

source§

type Element = MapE

source§

fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut Self::Element>
where Self::Key: Borrow<Q>, Q: ?Sized + Hash + Eq + Ord,

source§

fn insert<K, V>(&mut self, k: K, v: V) -> Option<Self::Element>
where K: Into<Self::Key>, V: Into<Self::Element>, Self::Key: Hash + Eq,

source§

fn remove<Q>(&mut self, k: &Q) -> Option<Self::Element>
where Self::Key: Borrow<Q>, Q: ?Sized + Hash + Eq + Ord,

Implementors§