pub struct Object<S> { /* private fields */ }
Expand description
An 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>>
pub fn add_field<K>(&mut self, k: K, value: Value<S>) -> Option<Value<S>>
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
Trait Implementations§
Source§impl<K, S> FromIterator<(K, Value<S>)> for Object<S>
impl<K, S> FromIterator<(K, Value<S>)> for Object<S>
Source§impl<S> IntoIterator for Object<S>
impl<S> IntoIterator for Object<S>
impl<S> StructuralPartialEq for Object<S>
Auto Trait Implementations§
impl<S> Freeze for Object<S>
impl<S> RefUnwindSafe for Object<S>where
S: RefUnwindSafe,
impl<S> Send for Object<S>where
S: Send,
impl<S> Sync for Object<S>where
S: Sync,
impl<S> Unpin for Object<S>where
S: Unpin,
impl<S> UnwindSafe for Object<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more