Skip to content

Commit d02128f

Browse files
committed
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.
1 parent 649b632 commit d02128f

File tree

1 file changed

+5
-6
lines changed
  • src/liballoc/collections/btree

1 file changed

+5
-6
lines changed

src/liballoc/collections/btree/map.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -2499,15 +2499,14 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
24992499
///
25002500
/// ```
25012501
/// use std::collections::BTreeMap;
2502+
/// use std::collections::btree_map::Entry;
25022503
///
2503-
/// let mut count: BTreeMap<&str, usize> = BTreeMap::new();
2504+
/// let mut map: BTreeMap<&str, u32> = BTreeMap::new();
25042505
///
2505-
/// // count the number of occurrences of letters in the vec
2506-
/// for x in vec!["a","b","a","c","a","b"] {
2507-
/// *count.entry(x).or_insert(0) += 1;
2506+
/// if let Entry::Vacant(o) = map.entry("poneyland") {
2507+
/// o.insert(37);
25082508
/// }
2509-
///
2510-
/// assert_eq!(count["a"], 3);
2509+
/// assert_eq!(map["poneyland"], 37);
25112510
/// ```
25122511
#[stable(feature = "rust1", since = "1.0.0")]
25132512
pub fn insert(self, value: V) -> &'a mut V {

0 commit comments

Comments
 (0)