1
Fork 0

Use IntoIterator for array impl everywhere.

This commit is contained in:
Mara Bos 2021-09-03 12:36:33 +02:00
parent b34cf1a9e1
commit 1acb44f03c
21 changed files with 41 additions and 50 deletions

View file

@ -1500,7 +1500,7 @@ impl<T: Ord, const N: usize> From<[T; N]> for BinaryHeap<T> {
/// }
/// ```
fn from(arr: [T; N]) -> Self {
core::array::IntoIter::new(arr).collect()
Self::from_iter(arr)
}
}

View file

@ -1305,11 +1305,11 @@ impl<K, V> BTreeMap<K, V> {
pub(crate) fn bulk_build_from_sorted_iter<I>(iter: I) -> Self
where
K: Ord,
I: Iterator<Item = (K, V)>,
I: IntoIterator<Item = (K, V)>,
{
let mut root = Root::new();
let mut length = 0;
root.bulk_push(DedupSortedIter::new(iter), &mut length);
root.bulk_push(DedupSortedIter::new(iter.into_iter()), &mut length);
BTreeMap { root: Some(root), length }
}
}
@ -1944,7 +1944,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
// use stable sort to preserve the insertion order.
inputs.sort_by(|a, b| a.0.cmp(&b.0));
BTreeMap::bulk_build_from_sorted_iter(inputs.into_iter())
BTreeMap::bulk_build_from_sorted_iter(inputs)
}
}
@ -2061,7 +2061,7 @@ impl<K: Ord, V, const N: usize> From<[(K, V); N]> for BTreeMap<K, V> {
// use stable sort to preserve the insertion order.
arr.sort_by(|a, b| a.0.cmp(&b.0));
BTreeMap::bulk_build_from_sorted_iter(core::array::IntoIter::new(arr))
BTreeMap::bulk_build_from_sorted_iter(arr)
}
}

View file

@ -1106,7 +1106,7 @@ impl<T: Ord, const N: usize> From<[T; N]> for BTreeSet<T> {
// use stable sort to preserve the insertion order.
arr.sort();
let iter = core::array::IntoIter::new(arr).map(|k| (k, ()));
let iter = IntoIterator::into_iter(arr).map(|k| (k, ()));
let map = BTreeMap::bulk_build_from_sorted_iter(iter);
BTreeSet { map }
}

View file

@ -1961,7 +1961,7 @@ impl<T, const N: usize> From<[T; N]> for LinkedList<T> {
/// assert_eq!(list1, list2);
/// ```
fn from(arr: [T; N]) -> Self {
core::array::IntoIter::new(arr).collect()
Self::from_iter(arr)
}
}