Skip to content

Commit 515c4d3

Browse files
committed
specialize zip: TrustedRandomAccess for Zip
1 parent a8f2e9b commit 515c4d3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libcore/iter/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,17 @@ impl<A, B> ZipImpl<A, B> for Zip<A, B>
785785
impl<A, B> ExactSizeIterator for Zip<A, B>
786786
where A: ExactSizeIterator, B: ExactSizeIterator {}
787787

788+
#[doc(hidden)]
789+
unsafe impl<A, B> TrustedRandomAccess for Zip<A, B>
790+
where A: TrustedRandomAccess,
791+
B: TrustedRandomAccess,
792+
{
793+
unsafe fn get_unchecked(&mut self, i: usize) -> (A::Item, B::Item) {
794+
(self.a.get_unchecked(i), self.b.get_unchecked(i))
795+
}
796+
797+
}
798+
788799
/// An iterator that maps the values of `iter` with `f`.
789800
///
790801
/// This `struct` is created by the [`map()`] method on [`Iterator`]. See its

0 commit comments

Comments
 (0)