File tree 1 file changed +10
-2
lines changed
library/std/src/collections/hash
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -971,7 +971,11 @@ where
971
971
/// map.insert("b", 2);
972
972
/// map.insert("c", 3);
973
973
///
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"]);
975
979
/// ```
976
980
#[ inline]
977
981
#[ stable( feature = "map_into_keys_values" , since = "1.54.0" ) ]
@@ -993,7 +997,11 @@ where
993
997
/// map.insert("b", 2);
994
998
/// map.insert("c", 3);
995
999
///
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]);
997
1005
/// ```
998
1006
#[ inline]
999
1007
#[ stable( feature = "map_into_keys_values" , since = "1.54.0" ) ]
You can’t perform that action at this time.
0 commit comments