diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index d50b212c7dd..f49a0c037de 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -351,18 +351,16 @@ impl DList { /// println!("{}", e); // prints 2, then 4, then 11, then 7, then 8 /// } /// ``` - pub fn insert_when(&mut self, elt: T, f: |&T, &T| -> bool) { - { - let mut it = self.iter_mut(); - loop { - match it.peek_next() { - None => break, - Some(x) => if f(x, &elt) { break } - } - it.next(); + pub fn insert_when(&mut self, elt: T, mut f: F) where F: FnMut(&T, &T) -> bool { + let mut it = self.iter_mut(); + loop { + match it.peek_next() { + None => break, + Some(x) => if f(x, &elt) { break } } - it.insert_next(elt); + it.next(); } + it.insert_next(elt); } /// Merges `other` into this `DList`, using the function `f`. @@ -371,7 +369,7 @@ impl DList { /// put `a` in the result if `f(a, b)` is true, and otherwise `b`. /// /// This operation should compute in O(max(N, M)) time. - pub fn merge(&mut self, mut other: DList, f: |&T, &T| -> bool) { + pub fn merge(&mut self, mut other: DList, mut f: F) where F: FnMut(&T, &T) -> bool { { let mut it = self.iter_mut(); loop {