pub struct Object<S> { /* private fields */ }
Expand description
A Object value
Implementations§
source§impl<S> Object<S>
impl<S> Object<S>
sourcepub fn with_capacity(size: usize) -> Self
pub fn with_capacity(size: usize) -> Self
Create a new Object value with a fixed number of preallocated slots for field-value pairs
sourcepub fn add_field<K>(&mut self, k: K, value: Value<S>) -> Option<Value<S>>where
K: AsRef<str> + Into<String>,
pub fn add_field<K>(&mut self, k: K, value: Value<S>) -> Option<Value<S>>where
K: AsRef<str> + Into<String>,
Add a new field with a value
If there is already a field for the given key any both values are objects, they are merged.
Otherwise the existing value is replaced and returned.
sourcepub fn contains_field<K: AsRef<str>>(&self, k: K) -> bool
pub fn contains_field<K: AsRef<str>>(&self, k: K) -> bool
Check if the object already contains a field with the given name
sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &Value<S>)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &Value<S>)>
Get a iterator over all field value pairs
sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (&String, &mut Value<S>)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&String, &mut Value<S>)>
Get a iterator over all mutable field value pairs
sourcepub fn field_count(&self) -> usize
pub fn field_count(&self) -> usize
Get the current number of fields