diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 0c0562a8b68d63a1a888beb11cf166f9d404a8a7..490f4e68bcc9d657cdfa8f71cbefbfa8352439d9 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -183,7 +183,7 @@ fn map B>(self, f: F) -> Map { /// ``` #[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 @@ fn idx(&mut self, index: uint) -> Option { /// 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 @@ fn size_hint(&self) -> (uint, Option) { } #[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() {