Skip to content

Commit 13f8f40

Browse files
committed
specialize zip: TrustedRandomAccess for Enumerate
1 parent 515c4d3 commit 13f8f40

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libcore/iter/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,15 @@ impl<I> DoubleEndedIterator for Enumerate<I> where
10921092
#[stable(feature = "rust1", since = "1.0.0")]
10931093
impl<I> ExactSizeIterator for Enumerate<I> where I: ExactSizeIterator {}
10941094

1095+
#[doc(hidden)]
1096+
unsafe impl<I> TrustedRandomAccess for Enumerate<I>
1097+
where I: TrustedRandomAccess
1098+
{
1099+
unsafe fn get_unchecked(&mut self, i: usize) -> (usize, I::Item) {
1100+
(self.count + i, self.iter.get_unchecked(i))
1101+
}
1102+
}
1103+
10951104
/// An iterator with a `peek()` that returns an optional reference to the next
10961105
/// element.
10971106
///

0 commit comments

Comments
 (0)