Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::cmp::Ordering;
use core::error::Error;
use core::fmt::{self, Debug};
use core::hash::{Hash, Hasher};
use core::iter::FusedIterator;
use core::iter::{FusedIterator, TrustedLen};
use core::marker::PhantomData;
use core::mem::{self, ManuallyDrop};
use core::ops::{Bound, Index, RangeBounds};
Expand Down Expand Up @@ -1624,6 +1624,9 @@ impl<K, V> ExactSizeIterator for Iter<'_, K, V> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V> TrustedLen for Iter<'_, K, V> {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<K, V> Clone for Iter<'_, K, V> {
fn clone(&self) -> Self {
Expand Down Expand Up @@ -1696,6 +1699,9 @@ impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V> TrustedLen for IterMut<'_, K, V> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<K, V> FusedIterator for IterMut<'_, K, V> {}

Expand Down Expand Up @@ -1817,6 +1823,9 @@ impl<K, V, A: Allocator + Clone> ExactSizeIterator for IntoIter<K, V, A> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V, A: Allocator + Clone> TrustedLen for IntoIter<K, V, A> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<K, V, A: Allocator + Clone> FusedIterator for IntoIter<K, V, A> {}

Expand Down Expand Up @@ -1865,6 +1874,9 @@ impl<K, V> ExactSizeIterator for Keys<'_, K, V> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V> TrustedLen for Keys<'_, K, V> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<K, V> FusedIterator for Keys<'_, K, V> {}

Expand Down Expand Up @@ -1920,6 +1932,9 @@ impl<K, V> ExactSizeIterator for Values<'_, K, V> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V> TrustedLen for Values<'_, K, V> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<K, V> FusedIterator for Values<'_, K, V> {}

Expand Down Expand Up @@ -2160,6 +2175,9 @@ impl<K, V> ExactSizeIterator for ValuesMut<'_, K, V> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V> TrustedLen for ValuesMut<'_, K, V> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<K, V> FusedIterator for ValuesMut<'_, K, V> {}

Expand Down Expand Up @@ -2222,6 +2240,9 @@ impl<K, V, A: Allocator + Clone> ExactSizeIterator for IntoKeys<K, V, A> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V, A: Allocator + Clone> TrustedLen for IntoKeys<K, V, A> {}

#[stable(feature = "map_into_keys_values", since = "1.54.0")]
impl<K, V, A: Allocator + Clone> FusedIterator for IntoKeys<K, V, A> {}

Expand Down Expand Up @@ -2273,6 +2294,9 @@ impl<K, V, A: Allocator + Clone> ExactSizeIterator for IntoValues<K, V, A> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V, A: Allocator + Clone> TrustedLen for IntoValues<K, V, A> {}

#[stable(feature = "map_into_keys_values", since = "1.54.0")]
impl<K, V, A: Allocator + Clone> FusedIterator for IntoValues<K, V, A> {}

Expand Down
12 changes: 11 additions & 1 deletion library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::cmp::Ordering::{self, Equal, Greater, Less};
use core::cmp::{max, min};
use core::fmt::{self, Debug};
use core::hash::{Hash, Hasher};
use core::iter::{FusedIterator, Peekable};
use core::iter::{FusedIterator, Peekable, TrustedLen};
use core::mem::ManuallyDrop;
use core::ops::{BitAnd, BitOr, BitXor, Bound, RangeBounds, Sub};

Expand Down Expand Up @@ -1753,6 +1753,7 @@ impl<T> Clone for Iter<'_, T> {
Iter { iter: self.iter.clone() }
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Iterator for Iter<'a, T> {
type Item = &'a T;
Expand Down Expand Up @@ -1783,19 +1784,24 @@ impl<'a, T> Iterator for Iter<'a, T> {
self.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
fn next_back(&mut self) -> Option<&'a T> {
self.iter.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> ExactSizeIterator for Iter<'_, T> {
fn len(&self) -> usize {
self.iter.len()
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<T> TrustedLen for Iter<'_, T> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<T> FusedIterator for Iter<'_, T> {}

Expand Down Expand Up @@ -1832,13 +1838,17 @@ impl<T, A: Allocator + Clone> DoubleEndedIterator for IntoIter<T, A> {
self.iter.next_back().map(|(k, _)| k)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T, A: Allocator + Clone> ExactSizeIterator for IntoIter<T, A> {
fn len(&self) -> usize {
self.iter.len()
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<T, A: Allocator + Clone> TrustedLen for IntoIter<T, A> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<T, A: Allocator + Clone> FusedIterator for IntoIter<T, A> {}

Expand Down
Loading