Skip to content

Commit 5e9ca5b

Browse files
author
Jorge Aparicio
committed
libcore: use unboxed closures in IteratorExt methods
1 parent 216bcfd commit 5e9ca5b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/libcore/iter.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ pub trait IteratorExt<A>: Iterator<A> {
521521
/// ```
522522
#[inline]
523523
#[unstable = "waiting for unboxed closures, just changed to take self by value"]
524-
fn fold<B>(mut self, init: B, f: |B, A| -> B) -> B {
524+
fn fold<B, F>(mut self, init: B, mut f: F) -> B where F: FnMut(B, A) -> B {
525525
let mut accum = init;
526526
for x in self {
527527
accum = f(accum, x);
@@ -555,7 +555,7 @@ pub trait IteratorExt<A>: Iterator<A> {
555555
/// ```
556556
#[inline]
557557
#[unstable = "waiting for unboxed closures, just changed to take self by value"]
558-
fn all(mut self, f: |A| -> bool) -> bool {
558+
fn all<F>(mut self, mut f: F) -> bool where F: FnMut(A) -> bool {
559559
for x in self { if !f(x) { return false; } }
560560
true
561561
}
@@ -573,7 +573,7 @@ pub trait IteratorExt<A>: Iterator<A> {
573573
/// ```
574574
#[inline]
575575
#[unstable = "waiting for unboxed closures"]
576-
fn any(&mut self, f: |A| -> bool) -> bool {
576+
fn any<F>(&mut self, mut f: F) -> bool where F: FnMut(A) -> bool {
577577
for x in *self { if f(x) { return true; } }
578578
false
579579
}
@@ -583,7 +583,7 @@ pub trait IteratorExt<A>: Iterator<A> {
583583
/// Does not consume the iterator past the first found element.
584584
#[inline]
585585
#[unstable = "waiting for unboxed closures"]
586-
fn find(&mut self, predicate: |&A| -> bool) -> Option<A> {
586+
fn find<P>(&mut self, mut predicate: P) -> Option<A> where P: FnMut(&A) -> bool {
587587
for x in *self {
588588
if predicate(&x) { return Some(x) }
589589
}
@@ -593,7 +593,7 @@ pub trait IteratorExt<A>: Iterator<A> {
593593
/// Return the index of the first element satisfying the specified predicate
594594
#[inline]
595595
#[unstable = "waiting for unboxed closures"]
596-
fn position(&mut self, predicate: |A| -> bool) -> Option<uint> {
596+
fn position<P>(&mut self, mut predicate: P) -> Option<uint> where P: FnMut(A) -> bool {
597597
let mut i = 0;
598598
for x in *self {
599599
if predicate(x) {
@@ -617,7 +617,7 @@ pub trait IteratorExt<A>: Iterator<A> {
617617
/// ```
618618
#[inline]
619619
#[unstable = "waiting for unboxed closures, just changed to take self by value"]
620-
fn max_by<B: Ord>(self, f: |&A| -> B) -> Option<A> {
620+
fn max_by<B: Ord, F>(self, mut f: F) -> Option<A> where F: FnMut(&A) -> B {
621621
self.fold(None, |max: Option<(A, B)>, x| {
622622
let x_val = f(&x);
623623
match max {
@@ -644,7 +644,7 @@ pub trait IteratorExt<A>: Iterator<A> {
644644
/// ```
645645
#[inline]
646646
#[unstable = "waiting for unboxed closures, just changed to take self by value"]
647-
fn min_by<B: Ord>(self, f: |&A| -> B) -> Option<A> {
647+
fn min_by<B: Ord, F>(self, mut f: F) -> Option<A> where F: FnMut(&A) -> B {
648648
self.fold(None, |min: Option<(A, B)>, x| {
649649
let x_val = f(&x);
650650
match min {

0 commit comments

Comments
 (0)