diff options
| author | bors <bors@rust-lang.org> | 2013-06-08 10:25:15 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-06-08 10:25:15 -0700 |
| commit | b8fa9d3be10e952fbcaf14f3098aebf13dedd7ec (patch) | |
| tree | f99d1c8374844ccf7a3368110d3e33c0e51f18bb /src/libstd/iterator.rs | |
| parent | e2ec8e71cec0373616953f8188cf7c4953269af0 (diff) | |
| parent | 98ba91f81bea38d8fc8bd5bc0cb44ac3e173a53c (diff) | |
| download | rust-b8fa9d3be10e952fbcaf14f3098aebf13dedd7ec.tar.gz rust-b8fa9d3be10e952fbcaf14f3098aebf13dedd7ec.zip | |
auto merge of #7015 : huonw/rust/each-fn-kill, r=thestinger
Continuation of #6995/#6999.
Diffstat (limited to 'src/libstd/iterator.rs')
| -rw-r--r-- | src/libstd/iterator.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index 4ed82f63b39..8803844fdd0 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -18,7 +18,6 @@ implementing the `Iterator` trait. */ use cmp; -use iter; use iter::{FromIter, Times}; use num::{Zero, One}; use option::{Option, Some, None}; @@ -326,7 +325,7 @@ pub trait IteratorUtil<A> { /// assert!(a.iter().all(|&x| *x > 0)); /// assert!(!a.iter().all(|&x| *x > 2)); /// ~~~ - fn all(&mut self, f: &fn(&A) -> bool) -> bool; + fn all(&mut self, f: &fn(A) -> bool) -> bool; /// Tests whether any element of an iterator satisfies the specified /// predicate. @@ -341,7 +340,7 @@ pub trait IteratorUtil<A> { /// assert!(it.any(|&x| *x == 3)); /// assert!(!it.any(|&x| *x == 3)); /// ~~~ - fn any(&mut self, f: &fn(&A) -> bool) -> bool; + fn any(&mut self, f: &fn(A) -> bool) -> bool; } /// Iterator adaptors provided for every `Iterator` implementation. The adaptor objects are also @@ -462,14 +461,14 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T { fn count(&mut self) -> uint { self.fold(0, |cnt, _x| cnt + 1) } #[inline(always)] - fn all(&mut self, f: &fn(&A) -> bool) -> bool { - for self.advance |x| { if !f(&x) { return false; } } + fn all(&mut self, f: &fn(A) -> bool) -> bool { + for self.advance |x| { if !f(x) { return false; } } return true; } #[inline(always)] - fn any(&mut self, f: &fn(&A) -> bool) -> bool { - for self.advance |x| { if f(&x) { return true; } } + fn any(&mut self, f: &fn(A) -> bool) -> bool { + for self.advance |x| { if f(x) { return true; } } return false; } } @@ -1080,18 +1079,18 @@ mod tests { #[test] fn test_all() { let v = ~&[1, 2, 3, 4, 5]; - assert!(v.iter().all(|&x| *x < 10)); + assert!(v.iter().all(|&x| x < 10)); assert!(!v.iter().all(|&x| x.is_even())); - assert!(!v.iter().all(|&x| *x > 100)); + assert!(!v.iter().all(|&x| x > 100)); assert!(v.slice(0, 0).iter().all(|_| fail!())); } #[test] fn test_any() { let v = ~&[1, 2, 3, 4, 5]; - assert!(v.iter().any(|&x| *x < 10)); + assert!(v.iter().any(|&x| x < 10)); assert!(v.iter().any(|&x| x.is_even())); - assert!(!v.iter().any(|&x| *x > 100)); + assert!(!v.iter().any(|&x| x > 100)); assert!(!v.slice(0, 0).iter().any(|_| fail!())); } } |
