Skip to main content

ObjectMut

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".

Implementations on Foreign Types§

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,

Source§

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

Available on crate feature halfbrown only.
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§