diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-04-21 21:35:39 +0200 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-06-14 15:51:49 +0200 |
| commit | 515c4d3c1e6c38ff2d8bd3b3b3e5bd8b6b4c2322 (patch) | |
| tree | dc627e39910f516c647caec335d06a8a8d912d6e | |
| parent | a8f2e9b3597b4ff5dc6230c327b35a2b0e7122c1 (diff) | |
specialize zip: TrustedRandomAccess for Zip
| -rw-r--r-- | src/libcore/iter/mod.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index c07a15ebc06..3ca37c40903 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -785,6 +785,17 @@ impl<A, B> ZipImpl<A, B> for Zip<A, B> impl<A, B> ExactSizeIterator for Zip<A, B> where A: ExactSizeIterator, B: ExactSizeIterator {} +#[doc(hidden)] +unsafe impl<A, B> TrustedRandomAccess for Zip<A, B> + where A: TrustedRandomAccess, + B: TrustedRandomAccess, +{ + unsafe fn get_unchecked(&mut self, i: usize) -> (A::Item, B::Item) { + (self.a.get_unchecked(i), self.b.get_unchecked(i)) + } + +} + /// An iterator that maps the values of `iter` with `f`. /// /// This `struct` is created by the [`map()`] method on [`Iterator`]. See its |
