Skip to content

Commit

Permalink
Specify only that duplicates are discarded, not the order.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid authored and gitbot committed Feb 22, 2025
1 parent b221158 commit 3cc63c3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
/// Constructs a `BTreeMap<K, V>` from an iterator of key-value pairs.
///
/// If the iterator produces any pairs with equal keys,
/// all but the last value for each such key are discarded.
/// all but one of the corresponding values will be dropped.
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> BTreeMap<K, V> {
let mut inputs: Vec<_> = iter.into_iter().collect();

Expand Down Expand Up @@ -2409,8 +2409,8 @@ where
impl<K: Ord, V, const N: usize> From<[(K, V); N]> for BTreeMap<K, V> {
/// Converts a `[(K, V); N]` into a `BTreeMap<K, V>`.
///
/// If any entries in the array have equal keys, all but the last entry for each such key
/// are discarded.
/// If any entries in the array have equal keys,
/// all but one of the corresponding values will be dropped.
///
/// ```
/// use std::collections::BTreeMap;
Expand Down
3 changes: 2 additions & 1 deletion alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,8 @@ impl<T: Ord, A: Allocator + Clone> BTreeSet<T, A> {
impl<T: Ord, const N: usize> From<[T; N]> for BTreeSet<T> {
/// Converts a `[T; N]` into a `BTreeSet<T>`.
///
/// If the array contains any equal values, all but the last instance of each are discarded.
/// If the array contains any equal values,
/// all but one will be dropped.
///
/// # Examples
///
Expand Down
6 changes: 3 additions & 3 deletions std/src/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,8 +1448,8 @@ where
{
/// Converts a `[(K, V); N]` into a `HashMap<K, V>`.
///
/// If any entries in the array have equal keys, all but the last entry for each such key
/// are discarded.
/// If any entries in the array have equal keys,
/// all but one of the corresponding values will be dropped.
///
/// # Examples
///
Expand Down Expand Up @@ -3227,7 +3227,7 @@ where
/// Constructs a `HashMap<K, V>` from an iterator of key-value pairs.
///
/// If the iterator produces any pairs with equal keys,
/// all but the last value for each such key are discarded.
/// all but one of the corresponding values will be dropped.
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> HashMap<K, V, S> {
let mut map = HashMap::with_hasher(Default::default());
map.extend(iter);
Expand Down
3 changes: 2 additions & 1 deletion std/src/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,8 @@ where
{
/// Converts a `[T; N]` into a `HashSet<T>`.
///
/// If the array contains any equal values, all but the last instance of each are discarded.
/// If the array contains any equal values,
/// all but one will be dropped.
///
/// # Examples
///
Expand Down

0 comments on commit 3cc63c3

Please sign in to comment.