diff options
| author | Joseph T Lyons <JosephTLyons@gmail.com> | 2021-12-02 12:27:23 -0500 |
|---|---|---|
| committer | Joseph T Lyons <JosephTLyons@gmail.com> | 2021-12-02 12:27:23 -0500 |
| commit | 440cffd551ef6040253e79e350d585cbd1471140 (patch) | |
| tree | 4d8d566d02e5088720f9d4e34e62c91c230bf113 /library/alloc/src | |
| parent | 80a308df322d426a5f98b0fe4d888cc701a854c6 (diff) | |
Use `BTreeMap::from()` instead of using `BTreeMap::new()` with `BTreeMap::insert()`
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/collections/btree/map.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 2ff7b0fbb75..f771c186e9a 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -2107,10 +2107,11 @@ impl<K, V> BTreeMap<K, V> { /// ``` /// use std::collections::BTreeMap; /// - /// let mut map = BTreeMap::new(); - /// map.insert("a", 1); - /// map.insert("b", 2); - /// map.insert("c", 3); + /// let mut map = BTreeMap::from([ + /// ("a", 1), + /// ("b", 2), + /// ("c", 3), + /// ]); /// /// // add 10 to the value if the key isn't "a" /// for (key, value) in map.iter_mut() { |
