Struct serde_json::Map [−][src]
pub struct Map<K, V> { /* fields omitted */ }
Represents a JSON key/value type.
Implementations
impl Map<String, Value>
[src]
impl Map<String, Value>
[src]pub fn new() -> Self
[src]
Makes a new empty Map.
pub fn with_capacity(capacity: usize) -> Self
[src]
Makes a new empty Map with the given initial capacity.
pub fn clear(&mut self)
[src]
Clears the map, removing all values.
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Returns a reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Returns true if the map contains a value for the specified key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Returns a mutable reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
pub fn insert(&mut self, k: String, v: Value) -> Option<Value>
[src]
Inserts a key-value pair into the map.
If the map did not have this key present, None
is returned.
If the map did have this key present, the value is updated, and the old value is returned.
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Removes a key from the map, returning the value at the key if the key was previously in the map.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
pub fn remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(String, Value)> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Removes a key from the map, returning the stored key and value if the key was previously in the map.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
pub fn append(&mut self, other: &mut Self)
[src]
Moves all elements from other into Self, leaving other empty.
pub fn entry<S>(&mut self, key: S) -> Entry<'_> where
S: Into<String>,
[src]
S: Into<String>,
Gets the given key’s corresponding entry in the map for in-place manipulation.
pub fn len(&self) -> usize
[src]
Returns the number of elements in the map.
pub fn is_empty(&self) -> bool
[src]
Returns true if the map contains no elements.
pub fn iter(&self) -> Iter<'_>ⓘ
[src]
Gets an iterator over the entries of the map.
pub fn iter_mut(&mut self) -> IterMut<'_>ⓘ
[src]
Gets a mutable iterator over the entries of the map.
pub fn keys(&self) -> Keys<'_>ⓘ
[src]
Gets an iterator over the keys of the map.
pub fn values(&self) -> Values<'_>ⓘ
[src]
Gets an iterator over the values of the map.
pub fn values_mut(&mut self) -> ValuesMut<'_>ⓘ
[src]
Gets an iterator over mutable values of the map.
Trait Implementations
impl Clone for Map<String, Value>
[src]
impl Clone for Map<String, Value>
[src]fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'de> Deserialize<'de> for Map<String, Value>
[src]
impl<'de> Deserialize<'de> for Map<String, Value>
[src]fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Extend<(String, Value)> for Map<String, Value>
[src]
impl Extend<(String, Value)> for Map<String, Value>
[src]fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (String, Value)>,
[src]
T: IntoIterator<Item = (String, Value)>,
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<'a, Q: ?Sized> Index<&'a Q> for Map<String, Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
impl<'a, Q: ?Sized> Index<&'a Q> for Map<String, Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]Access an element of this map. Panics if the given key is not present in the map.
match *val { Value::String(ref s) => Some(s.as_str()), Value::Array(ref arr) => arr[0].as_str(), Value::Object(ref map) => map["type"].as_str(), _ => None, }
impl<'a, Q: ?Sized> IndexMut<&'a Q> for Map<String, Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
impl<'a, Q: ?Sized> IndexMut<&'a Q> for Map<String, Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]Mutably access an element of this map. Panics if the given key is not present in the map.
map["key"] = json!("value");
impl<'a> IntoIterator for &'a Map<String, Value>
[src]
impl<'a> IntoIterator for &'a Map<String, Value>
[src]impl<'a> IntoIterator for &'a mut Map<String, Value>
[src]
impl<'a> IntoIterator for &'a mut Map<String, Value>
[src]impl IntoIterator for Map<String, Value>
[src]
impl IntoIterator for Map<String, Value>
[src]impl Eq for Map<String, Value>
[src]
Auto Trait Implementations
impl<K, V> RefUnwindSafe for Map<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for Map<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for Map<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
impl<K, V> Unpin for Map<K, V>
impl<K, V> UnwindSafe for Map<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]pub fn borrow(&self) -> &TⓘNotable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,