about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2014-12-02 17:49:42 -0500
committerJorge Aparicio <japaricious@gmail.com>2014-12-13 17:03:44 -0500
commit801ae1333c05ab641ff08c14fee776c08f42cff8 (patch)
tree54bcd60d4849836466405c781f4d43830556a51b /src
parent44b419b82084e1dc1abd8f8cb4b603fe1c43483c (diff)
downloadrust-801ae1333c05ab641ff08c14fee776c08f42cff8.tar.gz
rust-801ae1333c05ab641ff08c14fee776c08f42cff8.zip
libcore: use unboxed closures in the fields of `Filter`
Diffstat (limited to 'src')
-rw-r--r--src/libcore/iter.rs15
1 files changed, 9 insertions, 6 deletions
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<A>: Iterator<A> {
     /// ```
     #[inline]
     #[unstable = "waiting for unboxed closures"]
-    fn filter<'r>(self, predicate: |&A|: 'r -> bool) -> Filter<'r, A, Self> {
+    fn filter<P>(self, predicate: P) -> Filter<A, Self, P> where P: FnMut(&A) -> bool {
         Filter{iter: self, predicate: predicate}
     }
 
@@ -1438,13 +1438,13 @@ impl<A, B, I, F> RandomAccessIterator<B> for Map<A, B, I, F> 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<A, I, P> where I: Iterator<A>, P: FnMut(&A) -> bool {
+    iter: I,
+    predicate: P,
 }
 
 #[unstable = "trait is unstable"]
-impl<'a, A, T: Iterator<A>> Iterator<A> for Filter<'a, A, T> {
+impl<A, I, P> Iterator<A> for Filter<A, I, P> where I: Iterator<A>, P: FnMut(&A) -> bool {
     #[inline]
     fn next(&mut self) -> Option<A> {
         for x in self.iter {
@@ -1465,7 +1465,10 @@ impl<'a, A, T: Iterator<A>> Iterator<A> for Filter<'a, A, T> {
 }
 
 #[unstable = "trait is unstable"]
-impl<'a, A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A> for Filter<'a, A, T> {
+impl<A, I, P> DoubleEndedIterator<A> for Filter<A, I, P> where
+    I: DoubleEndedIterator<A>,
+    P: FnMut(&A) -> bool,
+{
     #[inline]
     fn next_back(&mut self) -> Option<A> {
         for x in self.iter.by_ref().rev() {