Trait simd_json::prelude::MutableObject

source ·
pub trait MutableObject {
    type Key: ?Sized;
    type Target;
    type Object;

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

    // Provided methods
    fn try_insert<K, V>(&mut self, k: K, v: V) -> Option<Self::Target>
       where Self::Key: From<K> + Hash + Eq,
             V: Into<Self::Target> { ... }
    fn try_remove<Q>(&mut self, k: &Q) -> Option<Self::Target>
       where Self::Key: Borrow<Q> + Hash + Eq,
             Q: Hash + Eq + Ord + ?Sized { ... }
}
Expand description

Prelude to include needed traits Mutatability for object like values

Required Associated Types§

source

type Key: ?Sized

The type for Object Keys

source

type Target

The type for Object Values

source

type Object

The type for Objects

Required Methods§

source

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

Insert into this Value as an Object. Will return an AccessError::NotAnObject if called on a Value that isn’t an object - otherwise will behave the same as HashMap::insert

§Errors

Will return Err if self is not an object.

source

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

Remove from this Value as an Object. Will return an AccessError::NotAnObject if called on a Value that isn’t an object - otherwise will behave the same as HashMap::remove

§Errors

Will return Err if self is not an Object.

source

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

Same as get but returns a mutable ref instead

Provided Methods§

source

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

Tries to insert into this Value as an Object. If the Value isn’t an object this opoeration will return None and have no effect.

source

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

Tries to remove from this Value as an Object. If the Value isn’t an object this opoeration will return None and have no effect.

Object Safety§

This trait is not object safe.

Implementors§