Skip to content

Commit 440cffd

Browse files
committed
Use BTreeMap::from() instead of using BTreeMap::new() with BTreeMap::insert()
1 parent 80a308d commit 440cffd

File tree

1 file changed

+5
-4
lines changed
  • library/alloc/src/collections/btree

1 file changed

+5
-4
lines changed

library/alloc/src/collections/btree/map.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2107,10 +2107,11 @@ impl<K, V> BTreeMap<K, V> {
21072107
/// ```
21082108
/// use std::collections::BTreeMap;
21092109
///
2110-
/// let mut map = BTreeMap::new();
2111-
/// map.insert("a", 1);
2112-
/// map.insert("b", 2);
2113-
/// map.insert("c", 3);
2110+
/// let mut map = BTreeMap::from([
2111+
/// ("a", 1),
2112+
/// ("b", 2),
2113+
/// ("c", 3),
2114+
/// ]);
21142115
///
21152116
/// // add 10 to the value if the key isn't "a"
21162117
/// for (key, value) in map.iter_mut() {

0 commit comments

Comments
 (0)