File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
library/std/src/collections/hash Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -971,7 +971,11 @@ where
971971 /// map.insert("b", 2);
972972 /// map.insert("c", 3);
973973 ///
974- /// let vec: Vec<&str> = map.into_keys().collect();
974+ /// let mut vec: Vec<&str> = map.into_keys().collect();
975+ /// // The `IntoKeys` iterator produces keys in arbitrary order, so the
976+ /// // keys must be sorted to test them against a sorted array.
977+ /// vec.sort_unstable();
978+ /// assert_eq!(vec, ["a", "b", "c"]);
975979 /// ```
976980 #[ inline]
977981 #[ stable( feature = "map_into_keys_values" , since = "1.54.0" ) ]
@@ -993,7 +997,11 @@ where
993997 /// map.insert("b", 2);
994998 /// map.insert("c", 3);
995999 ///
996- /// let vec: Vec<i32> = map.into_values().collect();
1000+ /// let mut vec: Vec<i32> = map.into_values().collect();
1001+ /// // The `IntoValues` iterator produces values in arbitrary order, so
1002+ /// // the values must be sorted to test them against a sorted array.
1003+ /// vec.sort_unstable();
1004+ /// assert_eq!(vec, [1, 2, 3]);
9971005 /// ```
9981006 #[ inline]
9991007 #[ stable( feature = "map_into_keys_values" , since = "1.54.0" ) ]
You can’t perform that action at this time.
0 commit comments