about summary refs log tree commit diff
diff options
context:
space:
mode:
authorccQpein <ccqpein@protonmail.com>2021-07-29 13:24:25 -0400
committerccQpein <ccqpein@protonmail.com>2021-08-22 09:21:00 -0400
commit6eefee1077cacd217ee512dc79445c8684334c40 (patch)
tree76835a3dac0a756b17d286f5d5732ff0bfad65ee
parent5fb3394cbdf0622c9d0c292feb55db0f4c828dc3 (diff)
downloadrust-6eefee1077cacd217ee512dc79445c8684334c40.tar.gz
rust-6eefee1077cacd217ee512dc79445c8684334c40.zip
Add doctests for 's into_values and into_keys methods
-rw-r--r--library/std/src/collections/hash/map.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs
index 933d686521e..42e9645a99d 100644
--- a/library/std/src/collections/hash/map.rs
+++ b/library/std/src/collections/hash/map.rs
@@ -971,7 +971,11 @@ where
     /// map.insert("b", 2);
     /// map.insert("c", 3);
     ///
-    /// let vec: Vec<&str> = map.into_keys().collect();
+    /// let mut vec: Vec<&str> = map.into_keys().collect();
+    /// // The `IntoKeys` iterator produces keys in arbitrary order, so the
+    /// // keys must be sorted to test them against a sorted array.
+    /// vec.sort_unstable();
+    /// assert_eq!(vec, ["a", "b", "c"]);
     /// ```
     #[inline]
     #[stable(feature = "map_into_keys_values", since = "1.54.0")]
@@ -993,7 +997,11 @@ where
     /// map.insert("b", 2);
     /// map.insert("c", 3);
     ///
-    /// let vec: Vec<i32> = map.into_values().collect();
+    /// let mut vec: Vec<i32> = map.into_values().collect();
+    /// // The `IntoValues` iterator produces values in arbitrary order, so
+    /// // the values must be sorted to test them against a sorted array.
+    /// vec.sort_unstable();
+    /// assert_eq!(vec, [1, 2, 3]);
     /// ```
     #[inline]
     #[stable(feature = "map_into_keys_values", since = "1.54.0")]