pub struct VObject(/* private fields */);Expand description
An object (map) value.
VObject is an ordered map of string keys to Values.
It preserves insertion order.
Storage modes:
- Small mode (default): inline array of KeyValuePair with linear search
- Large mode (std feature, >= 32 entries): IndexMap for O(1) lookups
Implementations§
Source§impl VObject
impl VObject
Sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
Creates a new object with the specified capacity.
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional more entries.
Sourcepub fn get_key_value(&self, key: &str) -> Option<(&VString, &Value)>
pub fn get_key_value(&self, key: &str) -> Option<(&VString, &Value)>
Gets a key-value pair by key.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true if the object contains the key.
Sourcepub fn insert(
&mut self,
key: impl Into<VString>,
value: impl Into<Value>,
) -> Option<Value>
pub fn insert( &mut self, key: impl Into<VString>, value: impl Into<Value>, ) -> Option<Value>
Inserts a key-value pair. Returns the old value if the key existed.
Sourcepub fn remove(&mut self, key: &str) -> Option<Value>
pub fn remove(&mut self, key: &str) -> Option<Value>
Removes a key-value pair. Returns the value if the key existed.
Sourcepub fn remove_entry(&mut self, key: &str) -> Option<(VString, Value)>
pub fn remove_entry(&mut self, key: &str) -> Option<(VString, Value)>
Removes and returns a key-value pair.
Sourcepub fn values_mut(&mut self) -> ValuesMut<'_> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_> ⓘ
Returns an iterator over mutable values.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity to match the length.
Trait Implementations§
Source§impl<K: Into<VString>, V: Into<Value>> Extend<(K, V)> for VObject
Available on crate feature alloc only.
impl<K: Into<VString>, V: Into<Value>> Extend<(K, V)> for VObject
Available on crate feature
alloc only.Source§fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<K: Into<VString>, V: Into<Value>> From<BTreeMap<K, V>> for VObject
Available on crate feature alloc only.
impl<K: Into<VString>, V: Into<Value>> From<BTreeMap<K, V>> for VObject
Available on crate feature
alloc only.Source§impl<K: Into<VString>, V: Into<Value>> From<HashMap<K, V>> for VObject
Available on crate feature std only.
impl<K: Into<VString>, V: Into<Value>> From<HashMap<K, V>> for VObject
Available on crate feature
std only.Source§impl<K: Into<VString>, V: Into<Value>> FromIterator<(K, V)> for VObject
Available on crate feature alloc only.
impl<K: Into<VString>, V: Into<Value>> FromIterator<(K, V)> for VObject
Available on crate feature
alloc only.Source§impl<'a> IntoIterator for &'a VObject
impl<'a> IntoIterator for &'a VObject
Source§impl<'a> IntoIterator for &'a mut VObject
impl<'a> IntoIterator for &'a mut VObject
Source§impl IntoIterator for VObject
impl IntoIterator for VObject
impl Eq for VObject
Auto Trait Implementations§
impl Freeze for VObject
impl RefUnwindSafe for VObject
impl Send for VObject
impl Sync for VObject
impl Unpin for VObject
impl UnwindSafe for VObject
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.