From 440cffd551ef6040253e79e350d585cbd1471140 Mon Sep 17 00:00:00 2001 From: Joseph T Lyons Date: Thu, 2 Dec 2021 12:27:23 -0500 Subject: Use `BTreeMap::from()` instead of using `BTreeMap::new()` with `BTreeMap::insert()` --- library/alloc/src/collections/btree/map.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'library/alloc/src') 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 BTreeMap { /// ``` /// 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() { -- cgit 1.4.1-3-g733a5 From 8bfc76dd6241aa7da0bc6660f0651e17092f8c93 Mon Sep 17 00:00:00 2001 From: Lucas Kent Date: Sun, 5 Dec 2021 01:22:49 +1100 Subject: Fix Vec::extend_from_slice docs --- library/alloc/src/vec/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'library/alloc/src') diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 88bde6e8ce4..af26a5b5998 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -2199,7 +2199,7 @@ impl Vec { /// Clones and appends all elements in a slice to the `Vec`. /// /// Iterates over the slice `other`, clones each element, and then appends - /// it to this `Vec`. The `other` vector is traversed in-order. + /// it to this `Vec`. The `other` slice is traversed in-order. /// /// Note that this function is same as [`extend`] except that it is /// specialized to work with slices instead. If and when Rust gets -- cgit 1.4.1-3-g733a5