Parametrize a few more things

This commit is contained in:
yanchith 2022-07-16 19:25:50 +02:00
parent d48b281468
commit 24df5f28e1

View File

@ -1421,19 +1421,22 @@ impl<T> FusedIterator for Iter<'_, T> {}
/// [`IntoIterator`]: core::iter::IntoIterator /// [`IntoIterator`]: core::iter::IntoIterator
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[derive(Clone)] #[derive(Clone)]
pub struct IntoIter<T> { pub struct IntoIter<
iter: vec::IntoIter<T>, T,
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
> {
iter: vec::IntoIter<T, A>,
} }
#[stable(feature = "collection_debug", since = "1.17.0")] #[stable(feature = "collection_debug", since = "1.17.0")]
impl<T: fmt::Debug> fmt::Debug for IntoIter<T> { impl<T: fmt::Debug, A: Allocator> fmt::Debug for IntoIter<T, A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("IntoIter").field(&self.iter.as_slice()).finish() f.debug_tuple("IntoIter").field(&self.iter.as_slice()).finish()
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<T> Iterator for IntoIter<T> { impl<T, A: Allocator> Iterator for IntoIter<T, A> {
type Item = T; type Item = T;
#[inline] #[inline]
@ -1448,7 +1451,7 @@ fn size_hint(&self) -> (usize, Option<usize>) {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<T> DoubleEndedIterator for IntoIter<T> { impl<T, A: Allocator> DoubleEndedIterator for IntoIter<T, A> {
#[inline] #[inline]
fn next_back(&mut self) -> Option<T> { fn next_back(&mut self) -> Option<T> {
self.iter.next_back() self.iter.next_back()
@ -1456,21 +1459,21 @@ fn next_back(&mut self) -> Option<T> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<T> ExactSizeIterator for IntoIter<T> { impl<T, A: Allocator> ExactSizeIterator for IntoIter<T, A> {
fn is_empty(&self) -> bool { fn is_empty(&self) -> bool {
self.iter.is_empty() self.iter.is_empty()
} }
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<T> FusedIterator for IntoIter<T> {} impl<T, A: Allocator> FusedIterator for IntoIter<T, A> {}
// In addition to the SAFETY invariants of the following three unsafe traits // In addition to the SAFETY invariants of the following three unsafe traits
// also refer to the vec::in_place_collect module documentation to get an overview // also refer to the vec::in_place_collect module documentation to get an overview
#[unstable(issue = "none", feature = "inplace_iteration")] #[unstable(issue = "none", feature = "inplace_iteration")]
#[doc(hidden)] #[doc(hidden)]
unsafe impl<T> SourceIter for IntoIter<T> { unsafe impl<T, A: Allocator> SourceIter for IntoIter<T, A> {
type Source = IntoIter<T>; type Source = IntoIter<T, A>;
#[inline] #[inline]
unsafe fn as_inner(&mut self) -> &mut Self::Source { unsafe fn as_inner(&mut self) -> &mut Self::Source {
@ -1480,9 +1483,9 @@ unsafe fn as_inner(&mut self) -> &mut Self::Source {
#[unstable(issue = "none", feature = "inplace_iteration")] #[unstable(issue = "none", feature = "inplace_iteration")]
#[doc(hidden)] #[doc(hidden)]
unsafe impl<I> InPlaceIterable for IntoIter<I> {} unsafe impl<I, A: Allocator> InPlaceIterable for IntoIter<I, A> {}
unsafe impl<I> AsVecIntoIter for IntoIter<I> { unsafe impl<I> AsVecIntoIter for IntoIter<I, Global> {
type Item = I; type Item = I;
fn as_into_iter(&mut self) -> &mut vec::IntoIter<Self::Item> { fn as_into_iter(&mut self) -> &mut vec::IntoIter<Self::Item> {
@ -1682,9 +1685,9 @@ fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> BinaryHeap<T> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<T> IntoIterator for BinaryHeap<T> { impl<T, A: Allocator> IntoIterator for BinaryHeap<T, A> {
type Item = T; type Item = T;
type IntoIter = IntoIter<T>; type IntoIter = IntoIter<T, A>;
/// Creates a consuming iterator, that is, one that moves each value out of /// Creates a consuming iterator, that is, one that moves each value out of
/// the binary heap in arbitrary order. The binary heap cannot be used /// the binary heap in arbitrary order. The binary heap cannot be used
@ -1704,7 +1707,7 @@ impl<T> IntoIterator for BinaryHeap<T> {
/// println!("{x}"); /// println!("{x}");
/// } /// }
/// ``` /// ```
fn into_iter(self) -> IntoIter<T> { fn into_iter(self) -> IntoIter<T, A> {
IntoIter { iter: self.data.into_iter() } IntoIter { iter: self.data.into_iter() }
} }
} }
@ -1720,7 +1723,7 @@ fn into_iter(self) -> Iter<'a, T> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Extend<T> for BinaryHeap<T> { impl<T: Ord, A: Allocator> Extend<T> for BinaryHeap<T, A> {
#[inline] #[inline]
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) { fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
<Self as SpecExtend<I>>::spec_extend(self, iter); <Self as SpecExtend<I>>::spec_extend(self, iter);
@ -1737,7 +1740,7 @@ fn extend_reserve(&mut self, additional: usize) {
} }
} }
impl<T: Ord, I: IntoIterator<Item = T>> SpecExtend<I> for BinaryHeap<T> { impl<T: Ord, A: Allocator, I: IntoIterator<Item = T>> SpecExtend<I> for BinaryHeap<T, A> {
default fn spec_extend(&mut self, iter: I) { default fn spec_extend(&mut self, iter: I) {
self.extend_desugared(iter.into_iter()); self.extend_desugared(iter.into_iter());
} }