about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-05-05 01:49:49 +0200
committerGitHub <noreply@github.com>2020-05-05 01:49:49 +0200
commitac84daf9306f57acf1f9d16e22079f1e3518e441 (patch)
tree3b9d67affe58b63e4cc17c51564c574ef8b0dad6
parenta93cc0664fee37010385b88918632332d2a4281f (diff)
parentd02128f92f5e7ce4911ee9ce77fc969e19aad5ad (diff)
downloadrust-ac84daf9306f57acf1f9d16e22079f1e3518e441.tar.gz
rust-ac84daf9306f57acf1f9d16e22079f1e3518e441.zip
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.
-rw-r--r--src/liballoc/collections/btree/map.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs
index c0b976565e4..b8f1a4199c6 100644
--- a/src/liballoc/collections/btree/map.rs
+++ b/src/liballoc/collections/btree/map.rs
@@ -2499,15 +2499,14 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
     ///
     /// ```
     /// 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
-    /// for x in vec!["a","b","a","c","a","b"] {
-    ///     *count.entry(x).or_insert(0) += 1;
+    /// if let Entry::Vacant(o) = map.entry("poneyland") {
+    ///     o.insert(37);
     /// }
-    ///
-    /// assert_eq!(count["a"], 3);
+    /// assert_eq!(map["poneyland"], 37);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn insert(self, value: V) -> &'a mut V {