Struct json_syntax::object::Object
source · [−]pub struct Object<M> { /* private fields */ }
Expand description
Object.
Implementations
sourceimpl<M> Object<M>
impl<M> Object<M>
pub fn new() -> Self
pub fn from_vec(entries: Vec<Entry<M>>) -> Self
pub fn capacity(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn entries(&self) -> &[Entry<M>]
pub fn iter(&self) -> Iter<'_, Entry<M>>
sourcepub fn get<Q: ?Sized>(&self, key: &Q) -> Values<'_, M>ⓘNotable traits for Values<'a, M>impl<'a, M> Iterator for Values<'a, M> type Item = &'a Meta<Value<M>, M>;
where
Q: Hash + Equivalent<Key>,
pub fn get<Q: ?Sized>(&self, key: &Q) -> Values<'_, M>ⓘNotable traits for Values<'a, M>impl<'a, M> Iterator for Values<'a, M> type Item = &'a Meta<Value<M>, M>;
where
Q: Hash + Equivalent<Key>,
Returns an iterator over the entries matching the given key.
Runs in O(1)
(average).
sourcepub fn get_entries<Q: ?Sized>(&self, key: &Q) -> Entries<'_, M>ⓘNotable traits for Entries<'a, M>impl<'a, M> Iterator for Entries<'a, M> type Item = &'a Entry<M>;
where
Q: Hash + Equivalent<Key>,
pub fn get_entries<Q: ?Sized>(&self, key: &Q) -> Entries<'_, M>ⓘNotable traits for Entries<'a, M>impl<'a, M> Iterator for Entries<'a, M> type Item = &'a Entry<M>;
where
Q: Hash + Equivalent<Key>,
Returns an iterator over the entries matching the given key.
Runs in O(1)
(average).
sourcepub fn get_with_index<Q: ?Sized>(&self, key: &Q) -> ValuesWithIndex<'_, M>ⓘNotable traits for ValuesWithIndex<'a, M>impl<'a, M> Iterator for ValuesWithIndex<'a, M> type Item = (usize, &'a Meta<Value<M>, M>);
where
Q: Hash + Equivalent<Key>,
pub fn get_with_index<Q: ?Sized>(&self, key: &Q) -> ValuesWithIndex<'_, M>ⓘNotable traits for ValuesWithIndex<'a, M>impl<'a, M> Iterator for ValuesWithIndex<'a, M> type Item = (usize, &'a Meta<Value<M>, M>);
where
Q: Hash + Equivalent<Key>,
Returns an iterator over the entries matching the given key.
Runs in O(1)
(average).
sourcepub fn get_entries_with_index<Q: ?Sized>(
&self,
key: &Q
) -> EntriesWithIndex<'_, M>ⓘNotable traits for EntriesWithIndex<'a, M>impl<'a, M> Iterator for EntriesWithIndex<'a, M> type Item = (usize, &'a Entry<M>);
where
Q: Hash + Equivalent<Key>,
pub fn get_entries_with_index<Q: ?Sized>(
&self,
key: &Q
) -> EntriesWithIndex<'_, M>ⓘNotable traits for EntriesWithIndex<'a, M>impl<'a, M> Iterator for EntriesWithIndex<'a, M> type Item = (usize, &'a Entry<M>);
where
Q: Hash + Equivalent<Key>,
Returns an iterator over the entries matching the given key.
Runs in O(1)
(average).
pub fn index_of<Q: ?Sized>(&self, key: &Q) -> Option<usize> where
Q: Hash + Equivalent<Key>,
pub fn redundant_index_of<Q: ?Sized>(&self, key: &Q) -> Option<usize> where
Q: Hash + Equivalent<Key>,
pub fn indexes_of<Q: ?Sized>(&self, key: &Q) -> Indexes<'_>ⓘNotable traits for Indexes<'a>impl<'a> Iterator for Indexes<'a> type Item = usize;
where
Q: Hash + Equivalent<Key>,
pub fn first(&self) -> Option<&Entry<M>>
pub fn last(&self) -> Option<&Entry<M>>
sourcepub fn push(&mut self, key: Meta<Key, M>, value: Meta<Value<M>, M>) -> bool
pub fn push(&mut self, key: Meta<Key, M>, value: Meta<Value<M>, M>) -> bool
Push the given key-value pair to the end of the object.
Returns true
if the key was not already present in the object,
and false
otherwise.
Any previous entry matching the key is not overridden: duplicates
are preserved, in order.
Runs in O(1)
.
pub fn push_entry(&mut self, entry: Entry<M>) -> bool
sourcepub fn remove_at(&mut self, index: usize) -> Option<Entry<M>>
pub fn remove_at(&mut self, index: usize) -> Option<Entry<M>>
Removes the entry at the given index.
sourcepub fn insert(
&mut self,
key: Meta<Key, M>,
value: Meta<Value<M>, M>
) -> Option<RemovedByInsertion<'_, M>>
pub fn insert(
&mut self,
key: Meta<Key, M>,
value: Meta<Value<M>, M>
) -> Option<RemovedByInsertion<'_, M>>
Inserts the given key-value pair.
If one or more entries are already matching the given key,
all of them are removed and returned in the resulting iterator.
Otherwise, None
is returned.
sourcepub fn remove<'q, Q: ?Sized>(
&mut self,
key: &'q Q
) -> RemovedEntries<'_, 'q, M, Q>ⓘNotable traits for RemovedEntries<'a, 'q, M, Q>impl<'a, 'q, M, Q: ?Sized> Iterator for RemovedEntries<'a, 'q, M, Q> where
Q: Hash + Equivalent<Key>, type Item = Entry<M>;
where
Q: Hash + Equivalent<Key>,
pub fn remove<'q, Q: ?Sized>(
&mut self,
key: &'q Q
) -> RemovedEntries<'_, 'q, M, Q>ⓘNotable traits for RemovedEntries<'a, 'q, M, Q>impl<'a, 'q, M, Q: ?Sized> Iterator for RemovedEntries<'a, 'q, M, Q> where
Q: Hash + Equivalent<Key>, type Item = Entry<M>;
where
Q: Hash + Equivalent<Key>,
Q: Hash + Equivalent<Key>, type Item = Entry<M>;
Remove all entries associated to the given key.
Runs in O(n)
time (average).
sourcepub fn map_metadata<N>(self, f: impl FnMut(M) -> N) -> Object<N>
pub fn map_metadata<N>(self, f: impl FnMut(M) -> N) -> Object<N>
Recursively maps the metadata inside the object.
Trait Implementations
sourceimpl<M> Extend<(Meta<SmallString<[u8; 16]>, M>, Meta<Value<M>, M>)> for Object<M>
impl<M> Extend<(Meta<SmallString<[u8; 16]>, M>, Meta<Value<M>, M>)> for Object<M>
sourcefn extend<I: IntoIterator<Item = (Meta<Key, M>, Meta<Value<M>, M>)>>(
&mut self,
iter: I
)
fn extend<I: IntoIterator<Item = (Meta<Key, M>, Meta<Value<M>, M>)>>(
&mut self,
iter: I
)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<M> Extend<Entry<M>> for Object<M>
impl<M> Extend<Entry<M>> for Object<M>
sourcefn extend<I: IntoIterator<Item = Entry<M>>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Entry<M>>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<M> FromIterator<(Meta<SmallString<[u8; 16]>, M>, Meta<Value<M>, M>)> for Object<M>
impl<M> FromIterator<(Meta<SmallString<[u8; 16]>, M>, Meta<Value<M>, M>)> for Object<M>
sourceimpl<M> FromIterator<Entry<M>> for Object<M>
impl<M> FromIterator<Entry<M>> for Object<M>
sourcefn from_iter<I: IntoIterator<Item = Entry<M>>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = Entry<M>>>(iter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<'a, M> IntoIterator for &'a Object<M>
impl<'a, M> IntoIterator for &'a Object<M>
sourceimpl<M> IntoIterator for Object<M>
impl<M> IntoIterator for Object<M>
sourceimpl<M: Ord> Ord for Object<M>
impl<M: Ord> Ord for Object<M>
sourceimpl<M: PartialOrd> PartialOrd<Object<M>> for Object<M>
impl<M: PartialOrd> PartialOrd<Object<M>> for Object<M>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<M> PrintWithSize for Object<M>
impl<M> PrintWithSize for Object<M>
sourceimpl<M> StrippedHash for Object<M>
impl<M> StrippedHash for Object<M>
fn stripped_hash<H: Hasher>(&self, state: &mut H)
sourceimpl<M> StrippedOrd for Object<M>
impl<M> StrippedOrd for Object<M>
fn stripped_cmp(&self, other: &Self) -> Ordering
sourceimpl<M> StrippedPartialEq<Object<M>> for Object<M>
impl<M> StrippedPartialEq<Object<M>> for Object<M>
fn stripped_eq(&self, other: &Self) -> bool
sourceimpl<M> StrippedPartialOrd<Object<M>> for Object<M>
impl<M> StrippedPartialOrd<Object<M>> for Object<M>
fn stripped_partial_cmp(&self, other: &Self) -> Option<Ordering>
impl<M: Eq> Eq for Object<M>
impl<M> StrippedEq for Object<M>
Auto Trait Implementations
impl<M> RefUnwindSafe for Object<M> where
M: RefUnwindSafe,
impl<M> Send for Object<M> where
M: Send,
impl<M> Sync for Object<M> where
M: Sync,
impl<M> Unpin for Object<M> where
M: Unpin,
impl<M> UnwindSafe for Object<M> where
M: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more