]> git.lizzy.rs Git - rust.git/commitdiff
libextra: Convert uses of `&fn(A)->B` to `|A|->B`.
authorPatrick Walton <pcwalton@mimiga.net>
Tue, 19 Nov 2013 05:54:13 +0000 (21:54 -0800)
committerPatrick Walton <pcwalton@mimiga.net>
Tue, 19 Nov 2013 20:40:19 +0000 (12:40 -0800)
16 files changed:
src/libextra/arc.rs
src/libextra/arena.rs
src/libextra/bitv.rs
src/libextra/dlist.rs
src/libextra/ebml.rs
src/libextra/getopts.rs
src/libextra/json.rs
src/libextra/list.rs
src/libextra/semver.rs
src/libextra/serialize.rs
src/libextra/smallintmap.rs
src/libextra/sync.rs
src/libextra/task_pool.rs
src/libextra/test.rs
src/libextra/treemap.rs
src/libextra/workcache.rs

index b3da9b4f16b889f270f1dacedb061d120bc2018e..4660036a774e093ff7839b58b51de68f720bff60 100644 (file)
@@ -220,7 +220,7 @@ pub fn new_with_condvars(user_data: T, num_condvars: uint) -> MutexArc<T> {
      * blocked on the mutex) will also fail immediately.
      */
     #[inline]
-    pub unsafe fn unsafe_access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
+    pub unsafe fn unsafe_access<U>(&self, blk: |x: &mut T| -> U) -> U {
         let state = self.x.get();
         // Borrowck would complain about this if the function were
         // not already unsafe. See borrow_rwlock, far below.
@@ -234,8 +234,7 @@ pub unsafe fn unsafe_access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
     /// As unsafe_access(), but with a condvar, as sync::mutex.lock_cond().
     #[inline]
     pub unsafe fn unsafe_access_cond<U>(&self,
-                                        blk: &fn(x: &mut T,
-                                                 c: &Condvar) -> U)
+                                        blk: |x: &mut T, c: &Condvar| -> U)
                                         -> U {
         let state = self.x.get();
         do (&(*state).lock).lock_cond |cond| {
@@ -284,15 +283,14 @@ impl<T:Freeze + Send> MutexArc<T> {
      * unsafe_access_cond.
      */
     #[inline]
-    pub fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
+    pub fn access<U>(&self, blk: |x: &mut T| -> U) -> U {
         unsafe { self.unsafe_access(blk) }
     }
 
     /// As unsafe_access_cond but safe and Freeze.
     #[inline]
     pub fn access_cond<U>(&self,
-                          blk: &fn(x: &mut T,
-                                   c: &Condvar) -> U)
+                          blk: |x: &mut T, c: &Condvar| -> U)
                           -> U {
         unsafe { self.unsafe_access_cond(blk) }
     }
@@ -389,7 +387,7 @@ pub fn new_with_condvars(user_data: T, num_condvars: uint) -> RWArc<T> {
      * poison the Arc, so subsequent readers and writers will both also fail.
      */
     #[inline]
-    pub fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
+    pub fn write<U>(&self, blk: |x: &mut T| -> U) -> U {
         unsafe {
             let state = self.x.get();
             do (*borrow_rwlock(state)).write {
@@ -403,7 +401,7 @@ pub fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
     /// As write(), but with a condvar, as sync::rwlock.write_cond().
     #[inline]
     pub fn write_cond<U>(&self,
-                         blk: &fn(x: &mut T, c: &Condvar) -> U)
+                         blk: |x: &mut T, c: &Condvar| -> U)
                          -> U {
         unsafe {
             let state = self.x.get();
@@ -427,7 +425,7 @@ pub fn write_cond<U>(&self,
      * Failing will unlock the Arc while unwinding. However, unlike all other
      * access modes, this will not poison the Arc.
      */
-    pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
+    pub fn read<U>(&self, blk: |x: &T| -> U) -> U {
         unsafe {
             let state = self.x.get();
             do (*state).lock.read {
@@ -457,7 +455,7 @@ pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
      * }
      * ```
      */
-    pub fn write_downgrade<U>(&self, blk: &fn(v: RWWriteMode<T>) -> U) -> U {
+    pub fn write_downgrade<U>(&self, blk: |v: RWWriteMode<T>| -> U) -> U {
         unsafe {
             let state = self.x.get();
             do (*borrow_rwlock(state)).write_downgrade |write_mode| {
@@ -539,7 +537,7 @@ pub struct RWReadMode<'self, T> {
 
 impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
     /// Access the pre-downgrade RWArc in write mode.
-    pub fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
+    pub fn write<U>(&mut self, blk: |x: &mut T| -> U) -> U {
         match *self {
             RWWriteMode {
                 data: &ref mut data,
@@ -555,7 +553,7 @@ pub fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
 
     /// Access the pre-downgrade RWArc in write mode with a condvar.
     pub fn write_cond<U>(&mut self,
-                         blk: &fn(x: &mut T, c: &Condvar) -> U)
+                         blk: |x: &mut T, c: &Condvar| -> U)
                          -> U {
         match *self {
             RWWriteMode {
@@ -580,7 +578,7 @@ pub fn write_cond<U>(&mut self,
 
 impl<'self, T:Freeze + Send> RWReadMode<'self, T> {
     /// Access the post-downgrade rwlock in read mode.
-    pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
+    pub fn read<U>(&self, blk: |x: &T| -> U) -> U {
         match *self {
             RWReadMode {
                 data: data,
index b684e0d429e316b94ecd92f14ec04441eb93de1d..2bb36e25fcb04afba523f382f6797b5c90a809a9 100644 (file)
@@ -184,7 +184,7 @@ fn alloc_pod_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
     }
 
     #[inline]
-    fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
+    fn alloc_pod<'a, T>(&'a mut self, op: || -> T) -> &'a T {
         unsafe {
             let tydesc = get_tydesc::<T>();
             let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
@@ -241,7 +241,7 @@ fn alloc_nonpod_inner(&mut self, n_bytes: uint, align: uint)
     }
 
     #[inline]
-    fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
+    fn alloc_nonpod<'a, T>(&'a mut self, op: || -> T) -> &'a T {
         unsafe {
             let tydesc = get_tydesc::<T>();
             let (ty_ptr, ptr) =
@@ -263,7 +263,7 @@ fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
 
     // The external interface
     #[inline]
-    pub fn alloc<'a, T>(&'a self, op: &fn() -> T) -> &'a T {
+    pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
         unsafe {
             // XXX: Borrow check
             let this = transmute_mut(self);
index 96123ad75b250603a7dfa877773f33c25c833741..c68133dac10106e361885b9430561957828b3584 100644 (file)
@@ -40,7 +40,7 @@ pub fn new(bits: uint) -> SmallBitv {
     pub fn bits_op(&mut self,
                    right_bits: uint,
                    nbits: uint,
-                   f: &fn(uint, uint) -> uint)
+                   f: |uint, uint| -> uint)
                    -> bool {
         let mask = small_mask(nbits);
         let old_b: uint = self.bits;
@@ -140,7 +140,7 @@ pub fn new(storage: ~[uint]) -> BigBitv {
     pub fn process(&mut self,
                    b: &BigBitv,
                    nbits: uint,
-                   op: &fn(uint, uint) -> uint)
+                   op: |uint, uint| -> uint)
                    -> bool {
         let len = b.storage.len();
         assert_eq!(self.storage.len(), len);
@@ -161,7 +161,7 @@ pub fn process(&mut self,
     }
 
     #[inline]
-    pub fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) -> bool {
+    pub fn each_storage(&mut self, op: |v: &mut uint| -> bool) -> bool {
         self.storage.mut_iter().advance(|elt| op(elt))
     }
 
@@ -512,7 +512,7 @@ pub fn eq_vec(&self, v: &[bool]) -> bool {
         true
     }
 
-    pub fn ones(&self, f: &fn(uint) -> bool) -> bool {
+    pub fn ones(&self, f: |uint| -> bool) -> bool {
         range(0u, self.nbits).advance(|i| !self.get(i) || f(i))
     }
 
@@ -542,7 +542,7 @@ pub fn from_bools(bools: &[bool]) -> Bitv {
  * Create a `Bitv` of the specified length where the value at each
  * index is `f(index)`.
  */
-pub fn from_fn(len: uint, f: &fn(index: uint) -> bool) -> Bitv {
+pub fn from_fn(len: uint, f: |index: uint| -> bool) -> Bitv {
     let mut bitv = Bitv::new(len, false);
     for i in range(0u, len) {
         bitv.set(i, f(i));
@@ -557,7 +557,7 @@ fn index(&self, i: &uint) -> bool {
 }
 
 #[inline]
-fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool {
+fn iterate_bits(base: uint, bits: uint, f: |uint| -> bool) -> bool {
     if bits == 0 {
         return true;
     }
@@ -675,7 +675,7 @@ pub fn unwrap(self) -> Bitv {
     }
 
     #[inline]
-    fn other_op(&mut self, other: &BitvSet, f: &fn(uint, uint) -> uint) {
+    fn other_op(&mut self, other: &BitvSet, f: |uint, uint| -> uint) {
         fn nbits(mut w: uint) -> uint {
             let mut bits = 0;
             for _ in range(0u, uint::bits) {
@@ -722,7 +722,7 @@ pub fn iter<'a>(&'a self) -> BitvSetIterator<'a> {
         BitvSetIterator {set: self, next_idx: 0}
     }
 
-    pub fn difference(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
+    pub fn difference(&self, other: &BitvSet, f: |&uint| -> bool) -> bool {
         for (i, w1, w2) in self.common_iter(other) {
             if !iterate_bits(i, w1 & !w2, |b| f(&b)) {
                 return false
@@ -734,8 +734,8 @@ pub fn difference(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
         )
     }
 
-    pub fn symmetric_difference(&self, other: &BitvSet,
-                            f: &fn(&uint) -> bool) -> bool {
+    pub fn symmetric_difference(&self, other: &BitvSet, f: |&uint| -> bool)
+                                -> bool {
         for (i, w1, w2) in self.common_iter(other) {
             if !iterate_bits(i, w1 ^ w2, |b| f(&b)) {
                 return false
@@ -744,11 +744,11 @@ pub fn symmetric_difference(&self, other: &BitvSet,
         self.outlier_iter(other).advance(|(_, i, w)| iterate_bits(i, w, |b| f(&b)))
     }
 
-    pub fn intersection(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
+    pub fn intersection(&self, other: &BitvSet, f: |&uint| -> bool) -> bool {
         self.common_iter(other).advance(|(i, w1, w2)| iterate_bits(i, w1 & w2, |b| f(&b)))
     }
 
-    pub fn union(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
+    pub fn union(&self, other: &BitvSet, f: |&uint| -> bool) -> bool {
         for (i, w1, w2) in self.common_iter(other) {
             if !iterate_bits(i, w1 | w2, |b| f(&b)) {
                 return false
index f29cbd6ee5294cdb70f6662ca05d8249af914a24..418b8256189f940178413acd2921272bf4ea5253 100644 (file)
@@ -320,7 +320,7 @@ pub fn prepend(&mut self, mut other: DList<T>) {
     /// or at the end.
     ///
     /// O(N)
-    pub fn insert_when(&mut self, elt: T, f: &fn(&T, &T) -> bool) {
+    pub fn insert_when(&mut self, elt: T, f: |&T, &T| -> bool) {
         {
             let mut it = self.mut_iter();
             loop {
@@ -339,7 +339,7 @@ pub fn insert_when(&mut self, elt: T, f: &fn(&T, &T) -> bool) {
     /// put `a` in the result if `f(a, b)` is true, else `b`.
     ///
     /// O(max(N, M))
-    pub fn merge(&mut self, mut other: DList<T>, f: &fn(&T, &T) -> bool) {
+    pub fn merge(&mut self, mut other: DList<T>, f: |&T, &T| -> bool) {
         {
             let mut it = self.mut_iter();
             loop {
index c249a8c09f29b0695506d8bfd843b5dcc6eaf044..c82ee733a4cbe90f43be6cf588e7ef51f6391878 100644 (file)
@@ -216,7 +216,7 @@ pub fn get_doc(d: Doc, tg: uint) -> Doc {
         }
     }
 
-    pub fn docs(d: Doc, it: &fn(uint, Doc) -> bool) -> bool {
+    pub fn docs(d: Doc, it: |uint, Doc| -> bool) -> bool {
         let mut pos = d.start;
         while pos < d.end {
             let elt_tag = vuint_at(*d.data, pos);
@@ -230,7 +230,7 @@ pub fn docs(d: Doc, it: &fn(uint, Doc) -> bool) -> bool {
         return true;
     }
 
-    pub fn tagged_docs(d: Doc, tg: uint, it: &fn(Doc) -> bool) -> bool {
+    pub fn tagged_docs(d: Doc, tg: uint, it: |Doc| -> bool) -> bool {
         let mut pos = d.start;
         while pos < d.end {
             let elt_tag = vuint_at(*d.data, pos);
@@ -247,7 +247,7 @@ pub fn tagged_docs(d: Doc, tg: uint, it: &fn(Doc) -> bool) -> bool {
         return true;
     }
 
-    pub fn with_doc_data<T>(d: Doc, f: &fn(x: &[u8]) -> T) -> T {
+    pub fn with_doc_data<T>(d: Doc, f: |x: &[u8]| -> T) -> T {
         f(d.data.slice(d.start, d.end))
     }
 
@@ -332,7 +332,7 @@ fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> Doc {
         }
 
         fn push_doc<T>(&mut self, exp_tag: EbmlEncoderTag,
-                       f: &fn(&mut Decoder) -> T) -> T {
+                       f: |&mut Decoder| -> T) -> T {
             let d = self.next_doc(exp_tag);
             let old_parent = self.parent;
             let old_pos = self.pos;
@@ -352,8 +352,7 @@ fn _next_uint(&mut self, exp_tag: EbmlEncoderTag) -> uint {
     }
 
     impl Decoder {
-        pub fn read_opaque<R>(&mut self, op: &fn(&mut Decoder, Doc) -> R)
-                              -> R {
+        pub fn read_opaque<R>(&mut self, op: |&mut Decoder, Doc| -> R) -> R {
             let doc = self.next_doc(EsOpaque);
 
             let (old_parent, old_pos) = (self.parent, self.pos);
@@ -424,10 +423,7 @@ fn read_str(&mut self) -> ~str {
         }
 
         // Compound types:
-        fn read_enum<T>(&mut self,
-                        name: &str,
-                        f: &fn(&mut Decoder) -> T)
-                        -> T {
+        fn read_enum<T>(&mut self, name: &str, f: |&mut Decoder| -> T) -> T {
             debug!("read_enum({})", name);
             self._check_label(name);
 
@@ -446,7 +442,7 @@ fn read_enum<T>(&mut self,
 
         fn read_enum_variant<T>(&mut self,
                                 _: &[&str],
-                                f: &fn(&mut Decoder, uint) -> T)
+                                f: |&mut Decoder, uint| -> T)
                                 -> T {
             debug!("read_enum_variant()");
             let idx = self._next_uint(EsEnumVid);
@@ -467,14 +463,14 @@ fn read_enum_variant<T>(&mut self,
 
         fn read_enum_variant_arg<T>(&mut self,
                                     idx: uint,
-                                    f: &fn(&mut Decoder) -> T) -> T {
+                                    f: |&mut Decoder| -> T) -> T {
             debug!("read_enum_variant_arg(idx={})", idx);
             f(self)
         }
 
         fn read_enum_struct_variant<T>(&mut self,
                                        _: &[&str],
-                                       f: &fn(&mut Decoder, uint) -> T)
+                                       f: |&mut Decoder, uint| -> T)
                                        -> T {
             debug!("read_enum_struct_variant()");
             let idx = self._next_uint(EsEnumVid);
@@ -496,7 +492,7 @@ fn read_enum_struct_variant<T>(&mut self,
         fn read_enum_struct_variant_field<T>(&mut self,
                                              name: &str,
                                              idx: uint,
-                                             f: &fn(&mut Decoder) -> T)
+                                             f: |&mut Decoder| -> T)
                                              -> T {
             debug!("read_enum_struct_variant_arg(name={}, idx={})", name, idx);
             f(self)
@@ -505,7 +501,7 @@ fn read_enum_struct_variant_field<T>(&mut self,
         fn read_struct<T>(&mut self,
                           name: &str,
                           _: uint,
-                          f: &fn(&mut Decoder) -> T)
+                          f: |&mut Decoder| -> T)
                           -> T {
             debug!("read_struct(name={})", name);
             f(self)
@@ -514,19 +510,19 @@ fn read_struct<T>(&mut self,
         fn read_struct_field<T>(&mut self,
                                 name: &str,
                                 idx: uint,
-                                f: &fn(&mut Decoder) -> T)
+                                f: |&mut Decoder| -> T)
                                 -> T {
             debug!("read_struct_field(name={}, idx={})", name, idx);
             self._check_label(name);
             f(self)
         }
 
-        fn read_tuple<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
+        fn read_tuple<T>(&mut self, f: |&mut Decoder, uint| -> T) -> T {
             debug!("read_tuple()");
             self.read_seq(f)
         }
 
-        fn read_tuple_arg<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
+        fn read_tuple_arg<T>(&mut self, idx: uint, f: |&mut Decoder| -> T)
                              -> T {
             debug!("read_tuple_arg(idx={})", idx);
             self.read_seq_elt(idx, f)
@@ -534,7 +530,7 @@ fn read_tuple_arg<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
 
         fn read_tuple_struct<T>(&mut self,
                                 name: &str,
-                                f: &fn(&mut Decoder, uint) -> T)
+                                f: |&mut Decoder, uint| -> T)
                                 -> T {
             debug!("read_tuple_struct(name={})", name);
             self.read_tuple(f)
@@ -542,13 +538,13 @@ fn read_tuple_struct<T>(&mut self,
 
         fn read_tuple_struct_arg<T>(&mut self,
                                     idx: uint,
-                                    f: &fn(&mut Decoder) -> T)
+                                    f: |&mut Decoder| -> T)
                                     -> T {
             debug!("read_tuple_struct_arg(idx={})", idx);
             self.read_tuple_arg(idx, f)
         }
 
-        fn read_option<T>(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T {
+        fn read_option<T>(&mut self, f: |&mut Decoder, bool| -> T) -> T {
             debug!("read_option()");
             do self.read_enum("Option") |this| {
                 do this.read_enum_variant(["None", "Some"]) |this, idx| {
@@ -561,7 +557,7 @@ fn read_option<T>(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T {
             }
         }
 
-        fn read_seq<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
+        fn read_seq<T>(&mut self, f: |&mut Decoder, uint| -> T) -> T {
             debug!("read_seq()");
             do self.push_doc(EsVec) |d| {
                 let len = d._next_uint(EsVecLen);
@@ -570,13 +566,13 @@ fn read_seq<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
             }
         }
 
-        fn read_seq_elt<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
+        fn read_seq_elt<T>(&mut self, idx: uint, f: |&mut Decoder| -> T)
                            -> T {
             debug!("read_seq_elt(idx={})", idx);
             self.push_doc(EsVecElt, f)
         }
 
-        fn read_map<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
+        fn read_map<T>(&mut self, f: |&mut Decoder, uint| -> T) -> T {
             debug!("read_map()");
             do self.push_doc(EsMap) |d| {
                 let len = d._next_uint(EsMapLen);
@@ -585,17 +581,13 @@ fn read_map<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
             }
         }
 
-        fn read_map_elt_key<T>(&mut self,
-                               idx: uint,
-                               f: &fn(&mut Decoder) -> T)
+        fn read_map_elt_key<T>(&mut self, idx: uint, f: |&mut Decoder| -> T)
                                -> T {
             debug!("read_map_elt_key(idx={})", idx);
             self.push_doc(EsMapKey, f)
         }
 
-        fn read_map_elt_val<T>(&mut self,
-                               idx: uint,
-                               f: &fn(&mut Decoder) -> T)
+        fn read_map_elt_val<T>(&mut self, idx: uint, f: |&mut Decoder| -> T)
                                -> T {
             debug!("read_map_elt_val(idx={})", idx);
             self.push_doc(EsMapVal, f)
@@ -682,7 +674,7 @@ pub fn end_tag(&mut self) {
             debug!("End tag (size = {})", size);
         }
 
-        pub fn wr_tag(&mut self, tag_id: uint, blk: &fn()) {
+        pub fn wr_tag(&mut self, tag_id: uint, blk: ||) {
             self.start_tag(tag_id);
             blk();
             self.end_tag();
@@ -779,7 +771,7 @@ fn _emit_label(&mut self, label: &str) {
     }
 
     impl Encoder {
-        pub fn emit_opaque(&mut self, f: &fn(&mut Encoder)) {
+        pub fn emit_opaque(&mut self, f: |&mut Encoder|) {
             self.start_tag(EsOpaque as uint);
             f(self);
             self.end_tag();
@@ -841,7 +833,7 @@ fn emit_str(&mut self, v: &str) {
             self.wr_tagged_str(EsStr as uint, v)
         }
 
-        fn emit_enum(&mut self, name: &str, f: &fn(&mut Encoder)) {
+        fn emit_enum(&mut self, name: &str, f: |&mut Encoder|) {
             self._emit_label(name);
             self.start_tag(EsEnum as uint);
             f(self);
@@ -852,14 +844,14 @@ fn emit_enum_variant(&mut self,
                              _: &str,
                              v_id: uint,
                              _: uint,
-                             f: &fn(&mut Encoder)) {
+                             f: |&mut Encoder|) {
             self._emit_tagged_uint(EsEnumVid, v_id);
             self.start_tag(EsEnumBody as uint);
             f(self);
             self.end_tag();
         }
 
-        fn emit_enum_variant_arg(&mut self, _: uint, f: &fn(&mut Encoder)) {
+        fn emit_enum_variant_arg(&mut self, _: uint, f: |&mut Encoder|) {
             f(self)
         }
 
@@ -867,83 +859,83 @@ fn emit_enum_struct_variant(&mut self,
                                     v_name: &str,
                                     v_id: uint,
                                     cnt: uint,
-                                    f: &fn(&mut Encoder)) {
+                                    f: |&mut Encoder|) {
             self.emit_enum_variant(v_name, v_id, cnt, f)
         }
 
         fn emit_enum_struct_variant_field(&mut self,
                                           _: &str,
                                           idx: uint,
-                                          f: &fn(&mut Encoder)) {
+                                          f: |&mut Encoder|) {
             self.emit_enum_variant_arg(idx, f)
         }
 
-        fn emit_struct(&mut self, _: &str, _len: uint, f: &fn(&mut Encoder)) {
+        fn emit_struct(&mut self, _: &str, _len: uint, f: |&mut Encoder|) {
             f(self)
         }
 
         fn emit_struct_field(&mut self,
                              name: &str,
                              _: uint,
-                             f: &fn(&mut Encoder)) {
+                             f: |&mut Encoder|) {
             self._emit_label(name);
             f(self)
         }
 
-        fn emit_tuple(&mut self, len: uint, f: &fn(&mut Encoder)) {
+        fn emit_tuple(&mut self, len: uint, f: |&mut Encoder|) {
             self.emit_seq(len, f)
         }
-        fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+        fn emit_tuple_arg(&mut self, idx: uint, f: |&mut Encoder|) {
             self.emit_seq_elt(idx, f)
         }
 
         fn emit_tuple_struct(&mut self,
                              _: &str,
                              len: uint,
-                             f: &fn(&mut Encoder)) {
+                             f: |&mut Encoder|) {
             self.emit_seq(len, f)
         }
-        fn emit_tuple_struct_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+        fn emit_tuple_struct_arg(&mut self, idx: uint, f: |&mut Encoder|) {
             self.emit_seq_elt(idx, f)
         }
 
-        fn emit_option(&mut self, f: &fn(&mut Encoder)) {
+        fn emit_option(&mut self, f: |&mut Encoder|) {
             self.emit_enum("Option", f);
         }
         fn emit_option_none(&mut self) {
             self.emit_enum_variant("None", 0, 0, |_| ())
         }
-        fn emit_option_some(&mut self, f: &fn(&mut Encoder)) {
+        fn emit_option_some(&mut self, f: |&mut Encoder|) {
             self.emit_enum_variant("Some", 1, 1, f)
         }
 
-        fn emit_seq(&mut self, len: uint, f: &fn(&mut Encoder)) {
+        fn emit_seq(&mut self, len: uint, f: |&mut Encoder|) {
             self.start_tag(EsVec as uint);
             self._emit_tagged_uint(EsVecLen, len);
             f(self);
             self.end_tag();
         }
 
-        fn emit_seq_elt(&mut self, _idx: uint, f: &fn(&mut Encoder)) {
+        fn emit_seq_elt(&mut self, _idx: uint, f: |&mut Encoder|) {
             self.start_tag(EsVecElt as uint);
             f(self);
             self.end_tag();
         }
 
-        fn emit_map(&mut self, len: uint, f: &fn(&mut Encoder)) {
+        fn emit_map(&mut self, len: uint, f: |&mut Encoder|) {
             self.start_tag(EsMap as uint);
             self._emit_tagged_uint(EsMapLen, len);
             f(self);
             self.end_tag();
         }
 
-        fn emit_map_elt_key(&mut self, _idx: uint, f: &fn(&mut Encoder)) {
+        fn emit_map_elt_key(&mut self, _idx: uint, f: |&mut Encoder|) {
             self.start_tag(EsMapKey as uint);
             f(self);
             self.end_tag();
         }
 
-        fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut Encoder)) {
+        fn emit_map_elt_val(&mut self, _idx: uint, f: |&mut Encoder|) {
             self.start_tag(EsMapVal as uint);
             f(self);
             self.end_tag();
index 918952132ab05c306666ba48459d19eb416bb228..d0df9dbe8383221f3f1932d46e2fc2939a88f1dd 100644 (file)
@@ -768,9 +768,8 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> ~str {
     ///
     /// Fails during iteration if the string contains a non-whitespace
     /// sequence longer than the limit.
-    fn each_split_within<'a>(ss: &'a str,
-                             lim: uint,
-                             it: &fn(&'a str) -> bool) -> bool {
+    fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
+                         -> bool {
         // Just for fun, let's write this as a state machine:
 
         enum SplitWithinState {
@@ -795,14 +794,14 @@ enum LengthLimit {
         let mut lim = lim;
 
         let mut cont = true;
-        let slice: &fn() = || { cont = it(ss.slice(slice_start, last_end)) };
+        let slice: || = || { cont = it(ss.slice(slice_start, last_end)) };
 
         // if the limit is larger than the string, lower it to save cycles
         if (lim >= fake_i) {
             lim = fake_i;
         }
 
-        let machine: &fn((uint, char)) -> bool = |(i, c)| {
+        let machine: |(uint, char)| -> bool = |(i, c)| {
             let whitespace = if ::std::char::is_whitespace(c) { Ws }       else { Cr };
             let limit      = if (i - slice_start + 1) <= lim  { UnderLim } else { OverLim };
 
index 7370dfafba9c8df1dd1175204b0b8b24b943c591..64655ca2b70f87c02b90e9e86d883f79f4ef0da4 100644 (file)
@@ -129,13 +129,13 @@ fn emit_str(&mut self, v: &str) {
         write!(self.wr, "{}", escape_str(v))
     }
 
-    fn emit_enum(&mut self, _name: &str, f: &fn(&mut Encoder)) { f(self) }
+    fn emit_enum(&mut self, _name: &str, f: |&mut Encoder|) { f(self) }
 
     fn emit_enum_variant(&mut self,
                          name: &str,
                          _id: uint,
                          cnt: uint,
-                         f: &fn(&mut Encoder)) {
+                         f: |&mut Encoder|) {
         // enums are encoded as strings or objects
         // Bunny => "Bunny"
         // Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]}
@@ -150,7 +150,7 @@ fn emit_enum_variant(&mut self,
         }
     }
 
-    fn emit_enum_variant_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+    fn emit_enum_variant_arg(&mut self, idx: uint, f: |&mut Encoder|) {
         if idx != 0 {
             write!(self.wr, ",");
         }
@@ -161,18 +161,18 @@ fn emit_enum_struct_variant(&mut self,
                                 name: &str,
                                 id: uint,
                                 cnt: uint,
-                                f: &fn(&mut Encoder)) {
+                                f: |&mut Encoder|) {
         self.emit_enum_variant(name, id, cnt, f)
     }
 
     fn emit_enum_struct_variant_field(&mut self,
                                       _: &str,
                                       idx: uint,
-                                      f: &fn(&mut Encoder)) {
+                                      f: |&mut Encoder|) {
         self.emit_enum_variant_arg(idx, f)
     }
 
-    fn emit_struct(&mut self, _: &str, _: uint, f: &fn(&mut Encoder)) {
+    fn emit_struct(&mut self, _: &str, _: uint, f: |&mut Encoder|) {
         write!(self.wr, r"\{");
         f(self);
         write!(self.wr, r"\}");
@@ -181,58 +181,58 @@ fn emit_struct(&mut self, _: &str, _: uint, f: &fn(&mut Encoder)) {
     fn emit_struct_field(&mut self,
                          name: &str,
                          idx: uint,
-                         f: &fn(&mut Encoder)) {
+                         f: |&mut Encoder|) {
         if idx != 0 { write!(self.wr, ",") }
         write!(self.wr, "{}:", escape_str(name));
         f(self);
     }
 
-    fn emit_tuple(&mut self, len: uint, f: &fn(&mut Encoder)) {
+    fn emit_tuple(&mut self, len: uint, f: |&mut Encoder|) {
         self.emit_seq(len, f)
     }
-    fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+    fn emit_tuple_arg(&mut self, idx: uint, f: |&mut Encoder|) {
         self.emit_seq_elt(idx, f)
     }
 
     fn emit_tuple_struct(&mut self,
                          _name: &str,
                          len: uint,
-                         f: &fn(&mut Encoder)) {
+                         f: |&mut Encoder|) {
         self.emit_seq(len, f)
     }
-    fn emit_tuple_struct_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+    fn emit_tuple_struct_arg(&mut self, idx: uint, f: |&mut Encoder|) {
         self.emit_seq_elt(idx, f)
     }
 
-    fn emit_option(&mut self, f: &fn(&mut Encoder)) { f(self); }
+    fn emit_option(&mut self, f: |&mut Encoder|) { f(self); }
     fn emit_option_none(&mut self) { self.emit_nil(); }
-    fn emit_option_some(&mut self, f: &fn(&mut Encoder)) { f(self); }
+    fn emit_option_some(&mut self, f: |&mut Encoder|) { f(self); }
 
-    fn emit_seq(&mut self, _len: uint, f: &fn(&mut Encoder)) {
+    fn emit_seq(&mut self, _len: uint, f: |&mut Encoder|) {
         write!(self.wr, "[");
         f(self);
         write!(self.wr, "]");
     }
 
-    fn emit_seq_elt(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+    fn emit_seq_elt(&mut self, idx: uint, f: |&mut Encoder|) {
         if idx != 0 {
             write!(self.wr, ",");
         }
         f(self)
     }
 
-    fn emit_map(&mut self, _len: uint, f: &fn(&mut Encoder)) {
+    fn emit_map(&mut self, _len: uint, f: |&mut Encoder|) {
         write!(self.wr, r"\{");
         f(self);
         write!(self.wr, r"\}");
     }
 
-    fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut Encoder)) {
+    fn emit_map_elt_key(&mut self, idx: uint, f: |&mut Encoder|) {
         if idx != 0 { write!(self.wr, ",") }
         f(self)
     }
 
-    fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut Encoder)) {
+    fn emit_map_elt_val(&mut self, _idx: uint, f: |&mut Encoder|) {
         write!(self.wr, ":");
         f(self)
     }
@@ -284,7 +284,7 @@ fn emit_f64(&mut self, v: f64) {
     fn emit_char(&mut self, v: char) { self.emit_str(str::from_char(v)) }
     fn emit_str(&mut self, v: &str) { write!(self.wr, "{}", escape_str(v)); }
 
-    fn emit_enum(&mut self, _name: &str, f: &fn(&mut PrettyEncoder)) {
+    fn emit_enum(&mut self, _name: &str, f: |&mut PrettyEncoder|) {
         f(self)
     }
 
@@ -292,7 +292,7 @@ fn emit_enum_variant(&mut self,
                          name: &str,
                          _: uint,
                          cnt: uint,
-                         f: &fn(&mut PrettyEncoder)) {
+                         f: |&mut PrettyEncoder|) {
         if cnt == 0 {
             write!(self.wr, "{}", escape_str(name));
         } else {
@@ -306,7 +306,7 @@ fn emit_enum_variant(&mut self,
 
     fn emit_enum_variant_arg(&mut self,
                              idx: uint,
-                             f: &fn(&mut PrettyEncoder)) {
+                             f: |&mut PrettyEncoder|) {
         if idx != 0 {
             write!(self.wr, ",\n");
         }
@@ -318,14 +318,14 @@ fn emit_enum_struct_variant(&mut self,
                                 name: &str,
                                 id: uint,
                                 cnt: uint,
-                                f: &fn(&mut PrettyEncoder)) {
+                                f: |&mut PrettyEncoder|) {
         self.emit_enum_variant(name, id, cnt, f)
     }
 
     fn emit_enum_struct_variant_field(&mut self,
                                       _: &str,
                                       idx: uint,
-                                      f: &fn(&mut PrettyEncoder)) {
+                                      f: |&mut PrettyEncoder|) {
         self.emit_enum_variant_arg(idx, f)
     }
 
@@ -333,7 +333,7 @@ fn emit_enum_struct_variant_field(&mut self,
     fn emit_struct(&mut self,
                    _: &str,
                    len: uint,
-                   f: &fn(&mut PrettyEncoder)) {
+                   f: |&mut PrettyEncoder|) {
         if len == 0 {
             write!(self.wr, "\\{\\}");
         } else {
@@ -348,7 +348,7 @@ fn emit_struct(&mut self,
     fn emit_struct_field(&mut self,
                          name: &str,
                          idx: uint,
-                         f: &fn(&mut PrettyEncoder)) {
+                         f: |&mut PrettyEncoder|) {
         if idx == 0 {
             write!(self.wr, "\n");
         } else {
@@ -358,30 +358,30 @@ fn emit_struct_field(&mut self,
         f(self);
     }
 
-    fn emit_tuple(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) {
+    fn emit_tuple(&mut self, len: uint, f: |&mut PrettyEncoder|) {
         self.emit_seq(len, f)
     }
-    fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) {
+    fn emit_tuple_arg(&mut self, idx: uint, f: |&mut PrettyEncoder|) {
         self.emit_seq_elt(idx, f)
     }
 
     fn emit_tuple_struct(&mut self,
                          _: &str,
                          len: uint,
-                         f: &fn(&mut PrettyEncoder)) {
+                         f: |&mut PrettyEncoder|) {
         self.emit_seq(len, f)
     }
     fn emit_tuple_struct_arg(&mut self,
                              idx: uint,
-                             f: &fn(&mut PrettyEncoder)) {
+                             f: |&mut PrettyEncoder|) {
         self.emit_seq_elt(idx, f)
     }
 
-    fn emit_option(&mut self, f: &fn(&mut PrettyEncoder)) { f(self); }
+    fn emit_option(&mut self, f: |&mut PrettyEncoder|) { f(self); }
     fn emit_option_none(&mut self) { self.emit_nil(); }
-    fn emit_option_some(&mut self, f: &fn(&mut PrettyEncoder)) { f(self); }
+    fn emit_option_some(&mut self, f: |&mut PrettyEncoder|) { f(self); }
 
-    fn emit_seq(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) {
+    fn emit_seq(&mut self, len: uint, f: |&mut PrettyEncoder|) {
         if len == 0 {
             write!(self.wr, "[]");
         } else {
@@ -393,7 +393,7 @@ fn emit_seq(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) {
         }
     }
 
-    fn emit_seq_elt(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) {
+    fn emit_seq_elt(&mut self, idx: uint, f: |&mut PrettyEncoder|) {
         if idx == 0 {
             write!(self.wr, "\n");
         } else {
@@ -403,7 +403,7 @@ fn emit_seq_elt(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) {
         f(self)
     }
 
-    fn emit_map(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) {
+    fn emit_map(&mut self, len: uint, f: |&mut PrettyEncoder|) {
         if len == 0 {
             write!(self.wr, "\\{\\}");
         } else {
@@ -415,7 +415,7 @@ fn emit_map(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) {
         }
     }
 
-    fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) {
+    fn emit_map_elt_key(&mut self, idx: uint, f: |&mut PrettyEncoder|) {
         if idx == 0 {
             write!(self.wr, "\n");
         } else {
@@ -425,7 +425,7 @@ fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) {
         f(self);
     }
 
-    fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut PrettyEncoder)) {
+    fn emit_map_elt_val(&mut self, _idx: uint, f: |&mut PrettyEncoder|) {
         write!(self.wr, ": ");
         f(self);
     }
@@ -921,14 +921,14 @@ fn read_str(&mut self) -> ~str {
         }
     }
 
-    fn read_enum<T>(&mut self, name: &str, f: &fn(&mut Decoder) -> T) -> T {
+    fn read_enum<T>(&mut self, name: &str, f: |&mut Decoder| -> T) -> T {
         debug!("read_enum({})", name);
         f(self)
     }
 
     fn read_enum_variant<T>(&mut self,
                             names: &[&str],
-                            f: &fn(&mut Decoder, uint) -> T)
+                            f: |&mut Decoder, uint| -> T)
                             -> T {
         debug!("read_enum_variant(names={:?})", names);
         let name = match self.stack.pop() {
@@ -957,9 +957,7 @@ fn read_enum_variant<T>(&mut self,
         f(self, idx)
     }
 
-    fn read_enum_variant_arg<T>(&mut self,
-                                idx: uint,
-                                f: &fn(&mut Decoder) -> T)
+    fn read_enum_variant_arg<T>(&mut self, idx: uint, f: |&mut Decoder| -> T)
                                 -> T {
         debug!("read_enum_variant_arg(idx={})", idx);
         f(self)
@@ -967,7 +965,7 @@ fn read_enum_variant_arg<T>(&mut self,
 
     fn read_enum_struct_variant<T>(&mut self,
                                    names: &[&str],
-                                   f: &fn(&mut Decoder, uint) -> T)
+                                   f: |&mut Decoder, uint| -> T)
                                    -> T {
         debug!("read_enum_struct_variant(names={:?})", names);
         self.read_enum_variant(names, f)
@@ -977,7 +975,7 @@ fn read_enum_struct_variant<T>(&mut self,
     fn read_enum_struct_variant_field<T>(&mut self,
                                          name: &str,
                                          idx: uint,
-                                         f: &fn(&mut Decoder) -> T)
+                                         f: |&mut Decoder| -> T)
                                          -> T {
         debug!("read_enum_struct_variant_field(name={}, idx={})", name, idx);
         self.read_enum_variant_arg(idx, f)
@@ -986,7 +984,7 @@ fn read_enum_struct_variant_field<T>(&mut self,
     fn read_struct<T>(&mut self,
                       name: &str,
                       len: uint,
-                      f: &fn(&mut Decoder) -> T)
+                      f: |&mut Decoder| -> T)
                       -> T {
         debug!("read_struct(name={}, len={})", name, len);
         let value = f(self);
@@ -997,7 +995,7 @@ fn read_struct<T>(&mut self,
     fn read_struct_field<T>(&mut self,
                             name: &str,
                             idx: uint,
-                            f: &fn(&mut Decoder) -> T)
+                            f: |&mut Decoder| -> T)
                             -> T {
         debug!("read_struct_field(name={}, idx={})", name, idx);
         match self.stack.pop() {
@@ -1017,22 +1015,19 @@ fn read_struct_field<T>(&mut self,
         }
     }
 
-    fn read_tuple<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
+    fn read_tuple<T>(&mut self, f: |&mut Decoder, uint| -> T) -> T {
         debug!("read_tuple()");
         self.read_seq(f)
     }
 
-    fn read_tuple_arg<T>(&mut self,
-                         idx: uint,
-                         f: &fn(&mut Decoder) -> T)
-                         -> T {
+    fn read_tuple_arg<T>(&mut self, idx: uint, f: |&mut Decoder| -> T) -> T {
         debug!("read_tuple_arg(idx={})", idx);
         self.read_seq_elt(idx, f)
     }
 
     fn read_tuple_struct<T>(&mut self,
                             name: &str,
-                            f: &fn(&mut Decoder, uint) -> T)
+                            f: |&mut Decoder, uint| -> T)
                             -> T {
         debug!("read_tuple_struct(name={})", name);
         self.read_tuple(f)
@@ -1040,20 +1035,20 @@ fn read_tuple_struct<T>(&mut self,
 
     fn read_tuple_struct_arg<T>(&mut self,
                                 idx: uint,
-                                f: &fn(&mut Decoder) -> T)
+                                f: |&mut Decoder| -> T)
                                 -> T {
         debug!("read_tuple_struct_arg(idx={})", idx);
         self.read_tuple_arg(idx, f)
     }
 
-    fn read_option<T>(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T {
+    fn read_option<T>(&mut self, f: |&mut Decoder, bool| -> T) -> T {
         match self.stack.pop() {
             Null => f(self, false),
             value => { self.stack.push(value); f(self, true) }
         }
     }
 
-    fn read_seq<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
+    fn read_seq<T>(&mut self, f: |&mut Decoder, uint| -> T) -> T {
         debug!("read_seq()");
         let len = match self.stack.pop() {
             List(list) => {
@@ -1068,12 +1063,12 @@ fn read_seq<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
         f(self, len)
     }
 
-    fn read_seq_elt<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) -> T {
+    fn read_seq_elt<T>(&mut self, idx: uint, f: |&mut Decoder| -> T) -> T {
         debug!("read_seq_elt(idx={})", idx);
         f(self)
     }
 
-    fn read_map<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
+    fn read_map<T>(&mut self, f: |&mut Decoder, uint| -> T) -> T {
         debug!("read_map()");
         let len = match self.stack.pop() {
             Object(obj) => {
@@ -1089,15 +1084,13 @@ fn read_map<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
         f(self, len)
     }
 
-    fn read_map_elt_key<T>(&mut self,
-                           idx: uint,
-                           f: &fn(&mut Decoder) -> T)
+    fn read_map_elt_key<T>(&mut self, idx: uint, f: |&mut Decoder| -> T)
                            -> T {
         debug!("read_map_elt_key(idx={})", idx);
         f(self)
     }
 
-    fn read_map_elt_val<T>(&mut self, idx: uint, f: &fn(&mut Decoder) -> T)
+    fn read_map_elt_val<T>(&mut self, idx: uint, f: |&mut Decoder| -> T)
                            -> T {
         debug!("read_map_elt_val(idx={})", idx);
         f(self)
@@ -1482,7 +1475,7 @@ fn test_write_object() {
         assert_eq!(a.clone(), from_str(a.to_pretty_str()).unwrap());
     }
 
-    fn with_str_writer(f: &fn(@mut io::Writer)) -> ~str {
+    fn with_str_writer(f: |@mut io::Writer|) -> ~str {
         use std::io::mem::MemWriter;
         use std::io::Decorator;
         use std::str;
index 5eada3dfb1a4e5b1365bd3de45832174005194aa..22d273e5747cd7d972ca05db6e693a54935fa36d 100644 (file)
@@ -44,7 +44,7 @@ pub fn from_vec<T:Clone + 'static>(v: &[T]) -> @List<T> {
  * * z - The initial value
  * * f - The function to apply
  */
-pub fn foldl<T:Clone,U>(z: T, ls: @List<U>, f: &fn(&T, &U) -> T) -> T {
+pub fn foldl<T:Clone,U>(z: T, ls: @List<U>, f: |&T, &U| -> T) -> T {
     let mut accum: T = z;
     do iter(ls) |elt| { accum = f(&accum, elt);}
     accum
@@ -57,7 +57,7 @@ pub fn foldl<T:Clone,U>(z: T, ls: @List<U>, f: &fn(&T, &U) -> T) -> T {
  * When function `f` returns true then an option containing the element
  * is returned. If `f` matches no elements then none is returned.
  */
-pub fn find<T:Clone>(ls: @List<T>, f: &fn(&T) -> bool) -> Option<T> {
+pub fn find<T:Clone>(ls: @List<T>, f: |&T| -> bool) -> Option<T> {
     let mut ls = ls;
     loop {
         ls = match *ls {
@@ -131,7 +131,7 @@ fn push<T:Clone>(ll: &mut @list<T>, vv: T) {
 */
 
 /// Iterate over a list
-pub fn iter<T>(l: @List<T>, f: &fn(&T)) {
+pub fn iter<T>(l: @List<T>, f: |&T|) {
     let mut cur = l;
     loop {
         cur = match *cur {
@@ -145,7 +145,7 @@ pub fn iter<T>(l: @List<T>, f: &fn(&T)) {
 }
 
 /// Iterate over a list
-pub fn each<T>(l: @List<T>, f: &fn(&T) -> bool) -> bool {
+pub fn each<T>(l: @List<T>, f: |&T| -> bool) -> bool {
     let mut cur = l;
     loop {
         cur = match *cur {
@@ -160,7 +160,7 @@ pub fn each<T>(l: @List<T>, f: &fn(&T) -> bool) -> bool {
 
 impl<T> MutList<T> {
     /// Iterate over a mutable list
-    pub fn each(@mut self, f: &fn(&mut T) -> bool) -> bool {
+    pub fn each(@mut self, f: |&mut T| -> bool) -> bool {
         let mut cur = self;
         loop {
             let borrowed = &mut *cur;
index 0ab38cdb5df83ff01b70be38a2485a5095d124a9..3de71c83c49bed706554c321cc1004a5981033bc 100644 (file)
@@ -145,8 +145,8 @@ fn ge(&self, other: &Version) -> bool {
     bad_parse: () -> ();
 }
 
-fn take_nonempty_prefix<T: Iterator<char>>(rdr: &mut T,
-                        pred: &fn(char) -> bool) -> (~str, Option<char>) {
+fn take_nonempty_prefix<T:Iterator<char>>(rdr: &mut T, pred: |char| -> bool)
+                        -> (~str, Option<char>) {
     let mut buf = ~"";
     let mut ch = rdr.next();
     loop {
index fb87414c8c364f5d088c60c82eea53deda3afb5f..8e75be651cfa604ce4cb12b6440514eea619a5c7 100644 (file)
@@ -47,48 +47,48 @@ pub trait Encoder {
     fn emit_str(&mut self, v: &str);
 
     // Compound types:
-    fn emit_enum(&mut self, name: &str, f: &fn(&mut Self));
+    fn emit_enum(&mut self, name: &str, f: |&mut Self|);
 
     fn emit_enum_variant(&mut self,
                          v_name: &str,
                          v_id: uint,
                          len: uint,
-                         f: &fn(&mut Self));
-    fn emit_enum_variant_arg(&mut self, a_idx: uint, f: &fn(&mut Self));
+                         f: |&mut Self|);
+    fn emit_enum_variant_arg(&mut self, a_idx: uint, f: |&mut Self|);
 
     fn emit_enum_struct_variant(&mut self,
                                 v_name: &str,
                                 v_id: uint,
                                 len: uint,
-                                f: &fn(&mut Self));
+                                f: |&mut Self|);
     fn emit_enum_struct_variant_field(&mut self,
                                       f_name: &str,
                                       f_idx: uint,
-                                      f: &fn(&mut Self));
+                                      f: |&mut Self|);
 
-    fn emit_struct(&mut self, name: &str, len: uint, f: &fn(&mut Self));
+    fn emit_struct(&mut self, name: &str, len: uint, f: |&mut Self|);
     fn emit_struct_field(&mut self,
                          f_name: &str,
                          f_idx: uint,
-                         f: &fn(&mut Self));
+                         f: |&mut Self|);
 
-    fn emit_tuple(&mut self, len: uint, f: &fn(&mut Self));
-    fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Self));
+    fn emit_tuple(&mut self, len: uint, f: |&mut Self|);
+    fn emit_tuple_arg(&mut self, idx: uint, f: |&mut Self|);
 
-    fn emit_tuple_struct(&mut self, name: &str, len: uint, f: &fn(&mut Self));
-    fn emit_tuple_struct_arg(&mut self, f_idx: uint, f: &fn(&mut Self));
+    fn emit_tuple_struct(&mut self, name: &str, len: uint, f: |&mut Self|);
+    fn emit_tuple_struct_arg(&mut self, f_idx: uint, f: |&mut Self|);
 
     // Specialized types:
-    fn emit_option(&mut self, f: &fn(&mut Self));
+    fn emit_option(&mut self, f: |&mut Self|);
     fn emit_option_none(&mut self);
-    fn emit_option_some(&mut self, f: &fn(&mut Self));
+    fn emit_option_some(&mut self, f: |&mut Self|);
 
-    fn emit_seq(&mut self, len: uint, f: &fn(this: &mut Self));
-    fn emit_seq_elt(&mut self, idx: uint, f: &fn(this: &mut Self));
+    fn emit_seq(&mut self, len: uint, f: |this: &mut Self|);
+    fn emit_seq_elt(&mut self, idx: uint, f: |this: &mut Self|);
 
-    fn emit_map(&mut self, len: uint, f: &fn(&mut Self));
-    fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut Self));
-    fn emit_map_elt_val(&mut self, idx: uint, f: &fn(&mut Self));
+    fn emit_map(&mut self, len: uint, f: |&mut Self|);
+    fn emit_map_elt_key(&mut self, idx: uint, f: |&mut Self|);
+    fn emit_map_elt_val(&mut self, idx: uint, f: |&mut Self|);
 }
 
 pub trait Decoder {
@@ -111,59 +111,56 @@ pub trait Decoder {
     fn read_str(&mut self) -> ~str;
 
     // Compound types:
-    fn read_enum<T>(&mut self, name: &str, f: &fn(&mut Self) -> T) -> T;
+    fn read_enum<T>(&mut self, name: &str, f: |&mut Self| -> T) -> T;
 
     fn read_enum_variant<T>(&mut self,
                             names: &[&str],
-                            f: &fn(&mut Self, uint) -> T)
+                            f: |&mut Self, uint| -> T)
                             -> T;
     fn read_enum_variant_arg<T>(&mut self,
                                 a_idx: uint,
-                                f: &fn(&mut Self) -> T)
+                                f: |&mut Self| -> T)
                                 -> T;
 
     fn read_enum_struct_variant<T>(&mut self,
                                    names: &[&str],
-                                   f: &fn(&mut Self, uint) -> T)
+                                   f: |&mut Self, uint| -> T)
                                    -> T;
     fn read_enum_struct_variant_field<T>(&mut self,
                                          &f_name: &str,
                                          f_idx: uint,
-                                         f: &fn(&mut Self) -> T)
+                                         f: |&mut Self| -> T)
                                          -> T;
 
-    fn read_struct<T>(&mut self,
-                      s_name: &str,
-                      len: uint,
-                      f: &fn(&mut Self) -> T)
+    fn read_struct<T>(&mut self, s_name: &str, len: uint, f: |&mut Self| -> T)
                       -> T;
     fn read_struct_field<T>(&mut self,
                             f_name: &str,
                             f_idx: uint,
-                            f: &fn(&mut Self) -> T)
+                            f: |&mut Self| -> T)
                             -> T;
 
-    fn read_tuple<T>(&mut self, f: &fn(&mut Self, uint) -> T) -> T;
-    fn read_tuple_arg<T>(&mut self, a_idx: uint, f: &fn(&mut Self) -> T) -> T;
+    fn read_tuple<T>(&mut self, f: |&mut Self, uint| -> T) -> T;
+    fn read_tuple_arg<T>(&mut self, a_idx: uint, f: |&mut Self| -> T) -> T;
 
     fn read_tuple_struct<T>(&mut self,
                             s_name: &str,
-                            f: &fn(&mut Self, uint) -> T)
+                            f: |&mut Self, uint| -> T)
                             -> T;
     fn read_tuple_struct_arg<T>(&mut self,
                                 a_idx: uint,
-                                f: &fn(&mut Self) -> T)
+                                f: |&mut Self| -> T)
                                 -> T;
 
     // Specialized types:
-    fn read_option<T>(&mut self, f: &fn(&mut Self, bool) -> T) -> T;
+    fn read_option<T>(&mut self, f: |&mut Self, bool| -> T) -> T;
 
-    fn read_seq<T>(&mut self, f: &fn(&mut Self, uint) -> T) -> T;
-    fn read_seq_elt<T>(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T;
+    fn read_seq<T>(&mut self, f: |&mut Self, uint| -> T) -> T;
+    fn read_seq_elt<T>(&mut self, idx: uint, f: |&mut Self| -> T) -> T;
 
-    fn read_map<T>(&mut self, f: &fn(&mut Self, uint) -> T) -> T;
-    fn read_map_elt_key<T>(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T;
-    fn read_map_elt_val<T>(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T;
+    fn read_map<T>(&mut self, f: |&mut Self, uint| -> T) -> T;
+    fn read_map_elt_key<T>(&mut self, idx: uint, f: |&mut Self| -> T) -> T;
+    fn read_map_elt_val<T>(&mut self, idx: uint, f: |&mut Self| -> T) -> T;
 }
 
 pub trait Encodable<S:Encoder> {
@@ -892,11 +889,11 @@ fn decode(d: &mut D) -> TreeSet<T> {
 // In some cases, these should eventually be coded as traits.
 
 pub trait EncoderHelpers {
-    fn emit_from_vec<T>(&mut self, v: &[T], f: &fn(&mut Self, v: &T));
+    fn emit_from_vec<T>(&mut self, v: &[T], f: |&mut Self, v: &T|);
 }
 
 impl<S:Encoder> EncoderHelpers for S {
-    fn emit_from_vec<T>(&mut self, v: &[T], f: &fn(&mut S, &T)) {
+    fn emit_from_vec<T>(&mut self, v: &[T], f: |&mut S, &T|) {
         do self.emit_seq(v.len()) |this| {
             for (i, e) in v.iter().enumerate() {
                 do this.emit_seq_elt(i) |this| {
@@ -908,11 +905,11 @@ fn emit_from_vec<T>(&mut self, v: &[T], f: &fn(&mut S, &T)) {
 }
 
 pub trait DecoderHelpers {
-    fn read_to_vec<T>(&mut self, f: &fn(&mut Self) -> T) -> ~[T];
+    fn read_to_vec<T>(&mut self, f: |&mut Self| -> T) -> ~[T];
 }
 
 impl<D:Decoder> DecoderHelpers for D {
-    fn read_to_vec<T>(&mut self, f: &fn(&mut D) -> T) -> ~[T] {
+    fn read_to_vec<T>(&mut self, f: |&mut D| -> T) -> ~[T] {
         do self.read_seq |this, len| {
             do vec::from_fn(len) |i| {
                 this.read_seq_elt(i, |this| f(this))
index 0ca0ff66039d859fbc1763d316c56f17b32fd3d5..119988735a75e07314303f2e1d6cc4746fcb47f4 100644 (file)
@@ -164,8 +164,11 @@ pub fn move_iter(&mut self)
 }
 
 impl<V:Clone> SmallIntMap<V> {
-    pub fn update_with_key(&mut self, key: uint, val: V,
-                           ff: &fn(uint, V, V) -> V) -> bool {
+    pub fn update_with_key(&mut self,
+                           key: uint,
+                           val: V,
+                           ff: |uint, V, V| -> V)
+                           -> bool {
         let new_val = match self.find(&key) {
             None => val,
             Some(orig) => ff(key, (*orig).clone(), val)
@@ -173,8 +176,7 @@ pub fn update_with_key(&mut self, key: uint, val: V,
         self.insert(key, new_val)
     }
 
-    pub fn update(&mut self, key: uint, newval: V, ff: &fn(V, V) -> V)
-                  -> bool {
+    pub fn update(&mut self, key: uint, newval: V, ff: |V, V| -> V) -> bool {
         self.update_with_key(key, newval, |_k, v, v1| ff(v,v1))
     }
 }
index 1988da2b0bafc2827230ec583e0335230f03b106..f01eb7ef2afe9267089cf6f034abe4e26f517ef5 100644 (file)
@@ -133,7 +133,7 @@ pub fn release(&self) {
         }
     }
 
-    pub fn access<U>(&self, blk: &fn() -> U) -> U {
+    pub fn access<U>(&self, blk: || -> U) -> U {
         do task::unkillable {
             do (|| {
                 self.acquire();
@@ -305,8 +305,12 @@ pub fn broadcast_on(&self, condvar_id: uint) -> uint {
 // something else next on success.
 #[inline]
 #[doc(hidden)]
-fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str,
-                        blk: &fn() -> U) -> U {
+fn check_cvar_bounds<U>(
+                     out_of_bounds: Option<uint>,
+                     id: uint,
+                     act: &str,
+                     blk: || -> U)
+                     -> U {
     match out_of_bounds {
         Some(0) =>
             fail!("{} with illegal ID {} - this lock has no condvars!", act, id),
@@ -320,7 +324,7 @@ fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str,
 impl Sem<~[WaitQueue]> {
     // The only other places that condvars get built are rwlock.write_cond()
     // and rwlock_write_mode.
-    pub fn access_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
+    pub fn access_cond<U>(&self, blk: |c: &Condvar| -> U) -> U {
         do self.access {
             blk(&Condvar { sem: self, order: Nothing, token: NonCopyable::new() })
         }
@@ -361,7 +365,7 @@ pub fn acquire(&self) { (&self.sem).acquire() }
     pub fn release(&self) { (&self.sem).release() }
 
     /// Run a function with ownership of one of the semaphore's resources.
-    pub fn access<U>(&self, blk: &fn() -> U) -> U { (&self.sem).access(blk) }
+    pub fn access<U>(&self, blk: || -> U) -> U { (&self.sem).access(blk) }
 }
 
 /****************************************************************************
@@ -399,12 +403,12 @@ pub fn new_with_condvars(num_condvars: uint) -> Mutex {
 
 
     /// Run a function with ownership of the mutex.
-    pub fn lock<U>(&self, blk: &fn() -> U) -> U {
+    pub fn lock<U>(&self, blk: || -> U) -> U {
         (&self.sem).access(blk)
     }
 
     /// Run a function with ownership of the mutex and a handle to a condvar.
-    pub fn lock_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
+    pub fn lock_cond<U>(&self, blk: |c: &Condvar| -> U) -> U {
         (&self.sem).access_cond(blk)
     }
 }
@@ -478,7 +482,7 @@ pub fn clone(&self) -> RWLock {
      * Run a function with the rwlock in read mode. Calls to 'read' from other
      * tasks may run concurrently with this one.
      */
-    pub fn read<U>(&self, blk: &fn() -> U) -> U {
+    pub fn read<U>(&self, blk: || -> U) -> U {
         unsafe {
             do task::unkillable {
                 do (&self.order_lock).access {
@@ -513,7 +517,7 @@ pub fn read<U>(&self, blk: &fn() -> U) -> U {
      * Run a function with the rwlock in write mode. No calls to 'read' or
      * 'write' from other tasks will run concurrently with this one.
      */
-    pub fn write<U>(&self, blk: &fn() -> U) -> U {
+    pub fn write<U>(&self, blk: || -> U) -> U {
         do task::unkillable {
             (&self.order_lock).acquire();
             do (&self.access_lock).access {
@@ -531,7 +535,7 @@ pub fn write<U>(&self, blk: &fn() -> U) -> U {
      * the waiting task is signalled. (Note: a writer that waited and then
      * was signalled might reacquire the lock before other waiting writers.)
      */
-    pub fn write_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
+    pub fn write_cond<U>(&self, blk: |c: &Condvar| -> U) -> U {
         // It's important to thread our order lock into the condvar, so that
         // when a cond.wait() wakes up, it uses it while reacquiring the
         // access lock. If we permitted a waking-up writer to "cut in line",
@@ -592,7 +596,7 @@ pub fn write_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
      * }
      * ```
      */
-    pub fn write_downgrade<U>(&self, blk: &fn(v: RWLockWriteMode) -> U) -> U {
+    pub fn write_downgrade<U>(&self, blk: |v: RWLockWriteMode| -> U) -> U {
         // Implementation slightly different from the slicker 'write's above.
         // The exit path is conditional on whether the caller downgrades.
         do task::unkillable {
@@ -671,9 +675,9 @@ pub struct RWLockReadMode<'self> { priv lock: &'self RWLock,
 
 impl<'self> RWLockWriteMode<'self> {
     /// Access the pre-downgrade rwlock in write mode.
-    pub fn write<U>(&self, blk: &fn() -> U) -> U { blk() }
+    pub fn write<U>(&self, blk: || -> U) -> U { blk() }
     /// Access the pre-downgrade rwlock in write mode with a condvar.
-    pub fn write_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
+    pub fn write_cond<U>(&self, blk: |c: &Condvar| -> U) -> U {
         // Need to make the condvar use the order lock when reacquiring the
         // access lock. See comment in RWLock::write_cond for why.
         blk(&Condvar { sem:        &self.lock.access_lock,
@@ -684,7 +688,7 @@ pub fn write_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U {
 
 impl<'self> RWLockReadMode<'self> {
     /// Access the post-downgrade rwlock in read mode.
-    pub fn read<U>(&self, blk: &fn() -> U) -> U { blk() }
+    pub fn read<U>(&self, blk: || -> U) -> U { blk() }
 }
 
 /****************************************************************************
@@ -1060,7 +1064,7 @@ fn test_mutex_no_condvars() {
     #[cfg(test)]
     pub enum RWLockMode { Read, Write, Downgrade, DowngradeRead }
     #[cfg(test)]
-    fn lock_rwlock_in_mode(x: &RWLock, mode: RWLockMode, blk: &fn()) {
+    fn lock_rwlock_in_mode(x: &RWLock, mode: RWLockMode, blk: ||) {
         match mode {
             Read => x.read(blk),
             Write => x.write(blk),
@@ -1221,7 +1225,7 @@ fn test_rwlock_cond_broadcast_helper(num_waiters: uint,
                                              dg1: bool,
                                              dg2: bool) {
         // Much like the mutex broadcast test. Downgrade-enabled.
-        fn lock_cond(x: &RWLock, downgrade: bool, blk: &fn(c: &Condvar)) {
+        fn lock_cond(x: &RWLock, downgrade: bool, blk: |c: &Condvar|) {
             if downgrade {
                 do x.write_downgrade |mode| {
                     do mode.write_cond |c| { blk(c) }
index 64fb954764a83efed2d3b8c1dbef0987f8ae056e..37deba43e3a15afb388401786ac158be05fabb0b 100644 (file)
@@ -49,7 +49,7 @@ impl<T> TaskPool<T> {
     /// local data to be kept around in that task.
     pub fn new(n_tasks: uint,
                opt_sched_mode: Option<SchedMode>,
-               init_fn_factory: &fn() -> proc(uint) -> T)
+               init_fn_factory: || -> proc(uint) -> T)
                -> TaskPool<T> {
         assert!(n_tasks >= 1);
 
@@ -97,7 +97,7 @@ pub fn execute(&mut self, f: proc(&T)) {
 
 #[test]
 fn test_task_pool() {
-    let f: &fn() -> proc(uint) -> uint = || {
+    let f: || -> proc(uint) -> uint = || {
         let g: proc(uint) -> uint = |i| i;
         g
     };
index acb3d538c982a620f8c88e32dcd9fa38f648528b..e9f38471d48629db0d0a632e47816e626cb21da9 100644 (file)
@@ -715,8 +715,7 @@ enum TestEvent {
 
 fn run_tests(opts: &TestOpts,
              tests: ~[TestDescAndFn],
-             callback: &fn(e: TestEvent)) {
-
+             callback: |e: TestEvent|) {
     let filtered_tests = filter_tests(opts, tests);
     let filtered_descs = filtered_tests.map(|t| t.desc.clone());
 
@@ -1058,7 +1057,7 @@ pub fn ratchet(&self, p: &Path, pct: Option<f64>) -> (MetricDiff, bool) {
 
 impl BenchHarness {
     /// Callback for benchmark functions to run in their body.
-    pub fn iter(&mut self, inner:&fn()) {
+    pub fn iter(&mut self, inner: ||) {
         self.ns_start = precise_time_ns();
         let k = self.iterations;
         for _ in range(0u64, k) {
@@ -1083,7 +1082,7 @@ pub fn ns_per_iter(&mut self) -> u64 {
         }
     }
 
-    pub fn bench_n(&mut self, n: u64, f: &fn(&mut BenchHarness)) {
+    pub fn bench_n(&mut self, n: u64, f: |&mut BenchHarness|) {
         self.iterations = n;
         debug!("running benchmark for {} iterations",
                n as uint);
@@ -1091,7 +1090,7 @@ pub fn bench_n(&mut self, n: u64, f: &fn(&mut BenchHarness)) {
     }
 
     // This is a more statistics-driven benchmark algorithm
-    pub fn auto_bench(&mut self, f: &fn(&mut BenchHarness)) -> stats::Summary {
+    pub fn auto_bench(&mut self, f: |&mut BenchHarness|) -> stats::Summary {
 
         // Initial bench run to get ballpark figure.
         let mut n = 1_u64;
@@ -1161,8 +1160,7 @@ pub fn auto_bench(&mut self, f: &fn(&mut BenchHarness)) -> stats::Summary {
 pub mod bench {
     use test::{BenchHarness, BenchSamples};
 
-    pub fn benchmark(f: &fn(&mut BenchHarness)) -> BenchSamples {
-
+    pub fn benchmark(f: |&mut BenchHarness|) -> BenchSamples {
         let mut bs = BenchHarness {
             iterations: 0,
             ns_start: 0,
index db5b12f021e5f3cc21efa4d3c43ee8275ed8d831..a19f501010e896d40488c69b06b2b7218a672715 100644 (file)
@@ -136,7 +136,7 @@ impl<K: TotalOrd, V> TreeMap<K, V> {
     pub fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
 
     /// Iterate over the map and mutate the contained values
-    pub fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool) -> bool {
+    pub fn mutate_values(&mut self, f: |&K, &mut V| -> bool) -> bool {
         mutate_values(&mut self.root, f)
     }
 
@@ -678,9 +678,12 @@ pub fn new(key: K, value: V) -> TreeNode<K, V> {
     }
 }
 
-fn mutate_values<'r, K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>,
-                                     f: &fn(&'r K, &'r mut V) -> bool)
-                                  -> bool {
+fn mutate_values<'r,
+                 K:TotalOrd,
+                 V>(
+                 node: &'r mut Option<~TreeNode<K,V>>,
+                 f: |&'r K, &'r mut V| -> bool)
+                 -> bool {
     match *node {
       Some(~TreeNode{key: ref key, value: ref mut value, left: ref mut left,
                      right: ref mut right, _}) => {
@@ -1400,8 +1403,10 @@ fn test_rev_iter() {
         }
     }
 
-    fn check(a: &[int], b: &[int], expected: &[int],
-             f: &fn(&TreeSet<int>, &TreeSet<int>, f: &fn(&int) -> bool) -> bool) {
+    fn check(a: &[int],
+             b: &[int],
+             expected: &[int],
+             f: |&TreeSet<int>, &TreeSet<int>, f: |&int| -> bool| -> bool) {
         let mut set_a = TreeSet::new();
         let mut set_b = TreeSet::new();
 
index 7ea7b513f4bd141c2be826a832221e82a8f8de18..09f95800b3dc1f71979366e0f5384279b313971a 100644 (file)
@@ -295,7 +295,12 @@ pub fn prep<'a>(&'a self, fn_name: &'a str) -> Prep<'a> {
         Prep::new(self, fn_name)
     }
 
-    pub fn with_prep<'a, T>(&'a self, fn_name: &'a str, blk: &fn(p: &mut Prep) -> T) -> T {
+    pub fn with_prep<'a,
+                     T>(
+                     &'a self,
+                     fn_name: &'a str,
+                     blk: |p: &mut Prep| -> T)
+                     -> T {
         let mut p = self.prep(fn_name);
         blk(&mut p)
     }