Struct stdcli::prelude::serde_json::value::Map
[−]
[src]
pub struct Map<K, V> { /* fields omitted */ }
Represents a JSON key/value type.
Methods
impl Map<String, Value>
[src]
fn new() -> Map<String, Value>
[src]
Makes a new empty Map.
fn with_capacity(capacity: usize) -> Map<String, Value>
[src]
Makes a new empty Map with the given initial capacity.
fn clear(&mut self)
[src]
Clears the map, removing all values.
fn get<Q>(&self, key: &Q) -> Option<&Value> where
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
[src]
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
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.
fn contains_key<Q>(&self, key: &Q) -> bool where
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
[src]
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
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.
fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Value> where
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
[src]
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
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.
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. The key is not updated, though; this matters for
types that can be ==
without being identical.
fn remove<Q>(&mut self, key: &Q) -> Option<Value> where
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
[src]
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
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.
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.
fn len(&self) -> usize
[src]
Returns the number of elements in the map.
fn is_empty(&self) -> bool
[src]
Returns true if the map contains no elements.
fn iter(&self) -> Iter
[src]
Gets an iterator over the entries of the map.
fn iter_mut(&mut self) -> IterMut
[src]
Gets a mutable iterator over the entries of the map.
fn keys(&self) -> Keys
[src]
Gets an iterator over the keys of the map.
fn values(&self) -> Values
[src]
Gets an iterator over the values of the map.
Trait Implementations
impl Serialize for Map<String, Value>
[src]
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
[src]
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Clone for Map<String, Value>
[src]
fn clone(&self) -> Map<String, Value>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq<Map<String, Value>> for Map<String, Value>
[src]
impl Debug for Map<String, Value>
[src]
fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
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)>,
Extends a collection with the contents of an iterator. Read more
impl Default for Map<String, Value>
[src]
impl<'a, Q> Index<&'a Q> for Map<String, Value> where
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
[src]
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
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> IntoIterator for &'a Map<String, Value>
[src]
type Item = (&'a String, &'a Value)
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> <&'a Map<String, Value> as IntoIterator>::IntoIter
[src]
Creates an iterator from a value. Read more
impl IntoIterator for Map<String, Value>
[src]
type Item = (String, Value)
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> <Map<String, Value> as IntoIterator>::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'a> IntoIterator for &'a mut Map<String, Value>
[src]
type Item = (&'a String, &'a mut Value)
The type of the elements being iterated over.
type IntoIter = IterMut<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> <&'a mut Map<String, Value> as IntoIterator>::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'de> Deserialize<'de> for Map<String, Value>
[src]
fn deserialize<D>(
deserializer: D
) -> Result<Map<String, Value>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
[src]
deserializer: D
) -> Result<Map<String, Value>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl FromIterator<(String, Value)> for Map<String, Value>
[src]
fn from_iter<T>(iter: T) -> Map<String, Value> where
T: IntoIterator<Item = (String, Value)>,
[src]
T: IntoIterator<Item = (String, Value)>,
Creates a value from an iterator. Read more
impl<'a, Q> IndexMut<&'a Q> for Map<String, Value> where
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
[src]
Q: Ord + Eq + Hash + ?Sized,
String: Borrow<Q>,
Mutably access an element of this map. Panics if the given key is not present in the map.
map["key"] = json!("value");