Skip to main content

MapAccessMut

Trait MapAccessMut 

Source
pub trait MapAccessMut {
    // Required method
    fn key_mut(&mut self, key: &str) -> Option<ObjectRefMut<'_>>;

    // Provided methods
    fn insert_key(
        &mut self,
        _key: &str,
        value: Object,
    ) -> Result<ObjectRefMut<'_>, Object> { ... }
    fn remove_key(&mut self, _key: &str) -> Option<Object> { ... }
}
Expand description

Mutable keyed entry access for ReflectMut::Map.

Required Methods§

Source

fn key_mut(&mut self, key: &str) -> Option<ObjectRefMut<'_>>

Returns a mutable value for a string-like key.

Provided Methods§

Source

fn insert_key( &mut self, _key: &str, value: Object, ) -> Result<ObjectRefMut<'_>, Object>

Inserts value under key, replacing any existing value, and returns a mutable view of it.

Returns value in Err if the key type cannot be built from a borrowed &str or the value type differs. Maps with &'static str keys reject insertion because a borrowed key cannot become 'static.

Source

fn remove_key(&mut self, _key: &str) -> Option<Object>

Removes the value stored under key and returns it.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<K, V, S> MapAccessMut for HashMap<K, V, S>
where K: Eq + Hash + 'static, V: MetaMut + 'static, S: BuildHasher + 'static,

Source§

fn key_mut(&mut self, key: &str) -> Option<ObjectRefMut<'_>>

Source§

fn insert_key( &mut self, key: &str, value: Object, ) -> Result<ObjectRefMut<'_>, Object>

Source§

fn remove_key(&mut self, key: &str) -> Option<Object>

Source§

impl<K, V> MapAccessMut for BTreeMap<K, V>
where K: Ord + 'static, V: MetaMut + 'static,

Source§

fn key_mut(&mut self, key: &str) -> Option<ObjectRefMut<'_>>

Source§

fn insert_key( &mut self, key: &str, value: Object, ) -> Result<ObjectRefMut<'_>, Object>

Source§

fn remove_key(&mut self, key: &str) -> Option<Object>

Implementors§