mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
Rollup merge of #71892 - integer32llc:btreemap-entry-vacant-docs, r=jonas-schievink
Update btree_map::VacantEntry::insert docs to actually call insert It looks like they were copied from the `or_insert` docs. This change makes the example more like the hash_map::VacantEntry::insert docs.
This commit is contained in:
commit
ac84daf930
@ -2499,15 +2499,14 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::collections::BTreeMap;
|
/// use std::collections::BTreeMap;
|
||||||
|
/// use std::collections::btree_map::Entry;
|
||||||
///
|
///
|
||||||
/// let mut count: BTreeMap<&str, usize> = BTreeMap::new();
|
/// let mut map: BTreeMap<&str, u32> = BTreeMap::new();
|
||||||
///
|
///
|
||||||
/// // count the number of occurrences of letters in the vec
|
/// if let Entry::Vacant(o) = map.entry("poneyland") {
|
||||||
/// for x in vec!["a","b","a","c","a","b"] {
|
/// o.insert(37);
|
||||||
/// *count.entry(x).or_insert(0) += 1;
|
|
||||||
/// }
|
/// }
|
||||||
///
|
/// assert_eq!(map["poneyland"], 37);
|
||||||
/// assert_eq!(count["a"], 3);
|
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn insert(self, value: V) -> &'a mut V {
|
pub fn insert(self, value: V) -> &'a mut V {
|
||||||
|
Loading…
Reference in New Issue
Block a user