Trait simd_json::prelude::derived::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
Mutatability for object like values
Required Associated Types§
Required Methods§
sourcefn insert<K, V>(
&mut self,
k: K,
v: V,
) -> Result<Option<Self::Target>, AccessError>
fn insert<K, V>( &mut self, k: K, v: V, ) -> Result<Option<Self::Target>, AccessError>
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.
sourcefn remove<Q>(&mut self, k: &Q) -> Result<Option<Self::Target>, AccessError>
fn remove<Q>(&mut self, k: &Q) -> Result<Option<Self::Target>, AccessError>
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.
Provided Methods§
sourcefn try_insert<K, V>(&mut self, k: K, v: V) -> Option<Self::Target>
fn try_insert<K, V>(&mut self, k: K, v: V) -> Option<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.
Object Safety§
This trait is not object safe.