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 @@ -969,7 +969,11 @@ where
969969 /// map.insert("b", 2);
970970 /// map.insert("c", 3);
971971 ///
972- /// let vec: Vec<&str> = map.into_keys().collect();
972+ /// let mut vec: Vec<&str> = map.into_keys().collect();
973+ /// // The `IntoKeys` iterator produces keys in arbitrary order, so the
974+ /// // keys must be sorted to test them against a sorted array.
975+ /// vec.sort_unstable();
976+ /// assert_eq!(vec, ["a", "b", "c"]);
973977 /// ```
974978 #[ inline]
975979 #[ stable( feature = "map_into_keys_values" , since = "1.54.0" ) ]
@@ -991,7 +995,11 @@ where
991995 /// map.insert("b", 2);
992996 /// map.insert("c", 3);
993997 ///
994- /// let vec: Vec<i32> = map.into_values().collect();
998+ /// let mut vec: Vec<i32> = map.into_values().collect();
999+ /// // The `IntoValues` iterator produces values in arbitrary order, so
1000+ /// // the values must be sorted to test them against a sorted array.
1001+ /// vec.sort_unstable();
1002+ /// assert_eq!(vec, [1, 2, 3]);
9951003 /// ```
9961004 #[ inline]
9971005 #[ stable( feature = "map_into_keys_values" , since = "1.54.0" ) ]
You can’t perform that action at this time.
0 commit comments