From a8f2e9b3597b4ff5dc6230c327b35a2b0e7122c1 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Thu, 21 Apr 2016 21:35:39 +0200 Subject: specialize zip: Specialize .zip() for TrustedRandomAccess iterators This allows common iterator compositions like a.zip(b) where a, b are slice::{Iter, IterMut} compile to *much* better code. --- src/libcore/iter/iterator.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libcore/iter/iterator.rs') diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 71ca5ccdc8d..8fb71295a88 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -23,6 +23,7 @@ use super::{Chain, Cycle, Cloned, Enumerate, Filter, FilterMap, FlatMap, Fuse, use super::ChainState; use super::{DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator, IntoIterator}; +use super::ZipImpl; fn _assert_is_object_safe(_: &Iterator) {} @@ -383,7 +384,7 @@ pub trait Iterator { fn zip(self, other: U) -> Zip where Self: Sized, U: IntoIterator { - Zip{a: self, b: other.into_iter()} + Zip::new(self, other.into_iter()) } /// Takes a closure and creates an iterator which calls that closure on each -- cgit 1.4.1-3-g733a5