pub struct Map<K, V> { /* private fields */ }
Expand description
Represents a TOML key/value type.
Implementations
sourceimpl Map<String, Value>
impl Map<String, Value>
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Makes a new empty Map with the given initial capacity.
sourcepub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&Value>where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&Value>where
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.
sourcepub fn contains_key<Q: ?Sized>(&self, key: &Q) -> boolwhere
String: Borrow<Q>,
Q: Ord + Eq + Hash,
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> boolwhere
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.
sourcepub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut Value>where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut Value>where
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.
sourcepub fn insert(&mut self, k: String, v: Value) -> Option<Value>
pub fn insert(&mut self, k: String, v: Value) -> Option<Value>
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.
sourcepub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<Value>where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<Value>where
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.
sourcepub fn entry<S>(&mut self, key: S) -> Entry<'_>where
S: Into<String>,
pub fn entry<S>(&mut self, key: S) -> Entry<'_>where
S: Into<String>,
Gets the given key’s corresponding entry in the map for in-place manipulation.
sourcepub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = (&'a String, &'a Value);
pub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = (&'a String, &'a Value);
Gets an iterator over the entries of the map.
sourcepub fn iter_mut(&mut self) -> IterMut<'_>ⓘNotable traits for IterMut<'a>impl<'a> Iterator for IterMut<'a> type Item = (&'a String, &'a mut Value);
pub fn iter_mut(&mut self) -> IterMut<'_>ⓘNotable traits for IterMut<'a>impl<'a> Iterator for IterMut<'a> type Item = (&'a String, &'a mut Value);
Gets a mutable iterator over the entries of the map.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Map<String, Value>
impl<'de> Deserialize<'de> for Map<String, Value>
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
sourceimpl Extend<(String, Value)> for Map<String, Value>
impl Extend<(String, Value)> for Map<String, Value>
sourcefn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = (String, Value)>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = (String, Value)>,
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)sourceimpl<'a, Q: ?Sized> Index<&'a Q> for Map<String, Value>where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
impl<'a, Q: ?Sized> Index<&'a Q> for Map<String, Value>where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Access an element of this map. Panics if the given key is not present in the map.
sourceimpl<'a, Q: ?Sized> IndexMut<&'a Q> for Map<String, Value>where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
impl<'a, Q: ?Sized> IndexMut<&'a Q> for Map<String, Value>where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Mutably access an element of this map. Panics if the given key is not present in the map.