Skip to content

Commit 6eefee1

Browse files
committed
Add doctests for 's into_values and into_keys methods
1 parent 5fb3394 commit 6eefee1

File tree

1 file changed

+10
-2
lines changed
  • library/std/src/collections/hash

1 file changed

+10
-2
lines changed

Diff for: library/std/src/collections/hash/map.rs

+10-2
Original file line numberDiff line numberDiff 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")]

0 commit comments

Comments
 (0)