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 @@ -969,7 +969,11 @@ where
969
969
/// map.insert("b", 2);
970
970
/// map.insert("c", 3);
971
971
///
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"]);
973
977
/// ```
974
978
#[ inline]
975
979
#[ stable( feature = "map_into_keys_values" , since = "1.54.0" ) ]
@@ -991,7 +995,11 @@ where
991
995
/// map.insert("b", 2);
992
996
/// map.insert("c", 3);
993
997
///
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]);
995
1003
/// ```
996
1004
#[ inline]
997
1005
#[ stable( feature = "map_into_keys_values" , since = "1.54.0" ) ]
You can’t perform that action at this time.
0 commit comments