diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 0c0562a8b68..490f4e68bcc 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -183,7 +183,7 @@ pub trait IteratorExt: Iterator { /// ``` #[inline] #[unstable = "waiting for unboxed closures"] - fn filter<'r>(self, predicate: |&A|: 'r -> bool) -> Filter<'r, A, Self> { + fn filter

(self, predicate: P) -> Filter where P: FnMut(&A) -> bool { Filter{iter: self, predicate: predicate} } @@ -1438,13 +1438,13 @@ impl RandomAccessIterator for Map where /// An iterator which filters the elements of `iter` with `predicate` #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[stable] -pub struct Filter<'a, A, T> { - iter: T, - predicate: |&A|: 'a -> bool +pub struct Filter where I: Iterator, P: FnMut(&A) -> bool { + iter: I, + predicate: P, } #[unstable = "trait is unstable"] -impl<'a, A, T: Iterator> Iterator for Filter<'a, A, T> { +impl Iterator for Filter where I: Iterator, P: FnMut(&A) -> bool { #[inline] fn next(&mut self) -> Option { for x in self.iter { @@ -1465,7 +1465,10 @@ impl<'a, A, T: Iterator> Iterator for Filter<'a, A, T> { } #[unstable = "trait is unstable"] -impl<'a, A, T: DoubleEndedIterator> DoubleEndedIterator for Filter<'a, A, T> { +impl DoubleEndedIterator for Filter where + I: DoubleEndedIterator, + P: FnMut(&A) -> bool, +{ #[inline] fn next_back(&mut self) -> Option { for x in self.iter.by_ref().rev() {