From 492677ec1e4e66a57a2fce78962db2f89932dd74 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 19 Nov 2013 12:21:21 -0800 Subject: libsyntax: Change all uses of `&fn` to `||`. --- src/libsyntax/ext/base.rs | 23 +++++++++++++++-------- src/libsyntax/ext/deriving/decodable.rs | 7 +++++-- src/libsyntax/ext/deriving/generic.rs | 27 +++++++++++++++------------ src/libsyntax/ext/deriving/rand.rs | 6 ++++-- 4 files changed, 39 insertions(+), 24 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 7ce73a4afef..448f8ee88f9 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -559,11 +559,11 @@ impl MapChain{ // should each_key and each_value operate on shadowed // names? I think not. // delaying implementing this.... - pub fn each_key (&self, _f: &fn (&K)->bool) { + pub fn each_key (&self, _f: |&K| -> bool) { fail!("unimplemented 2013-02-15T10:01"); } - pub fn each_value (&self, _f: &fn (&V) -> bool) { + pub fn each_value (&self, _f: |&V| -> bool) { fail!("unimplemented 2013-02-15T10:02"); } @@ -601,7 +601,11 @@ impl MapChain{ // ... there are definitely some opportunities for abstraction // here that I'm ignoring. (e.g., manufacturing a predicate on // the maps in the chain, and using an abstract "find". - pub fn insert_into_frame(&mut self, key: K, ext: @V, n: K, pred: &fn(&@V)->bool) { + pub fn insert_into_frame(&mut self, + key: K, + ext: @V, + n: K, + pred: |&@V| -> bool) { match *self { BaseMapChain (~ref mut map) => { if satisfies_pred(map,&n,pred) { @@ -622,10 +626,12 @@ impl MapChain{ } // returns true if the binding for 'n' satisfies 'pred' in 'map' -fn satisfies_pred(map : &mut HashMap, - n: &K, - pred: &fn(&V)->bool) - -> bool { +fn satisfies_pred( + map: &mut HashMap, + n: &K, + pred: |&V| -> bool) + -> bool { match map.find(n) { Some(ref v) => (pred(*v)), None => false @@ -637,7 +643,8 @@ mod test { use super::MapChain; use std::hashmap::HashMap; - #[test] fn testenv () { + #[test] + fn testenv() { let mut a = HashMap::new(); a.insert (@"abc",@15); let m = MapChain::new(~a); diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 3f745d64a7b..2f9222ccb56 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -124,9 +124,12 @@ fn decodable_substructure(cx: @ExtCtxt, span: Span, /// Create a decoder for a single enum variant/struct: /// - `outer_pat_ident` is the name of this enum variant/struct /// - `getarg` should retrieve the `uint`-th field with name `@str`. -fn decode_static_fields(cx: @ExtCtxt, outer_span: Span, outer_pat_ident: Ident, +fn decode_static_fields(cx: @ExtCtxt, + outer_span: Span, + outer_pat_ident: Ident, fields: &StaticFields, - getarg: &fn(Span, @str, uint) -> @Expr) -> @Expr { + getarg: |Span, @str, uint| -> @Expr) + -> @Expr { match *fields { Unnamed(ref fields) => { if fields.is_empty() { diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index aa83b7656a6..23dc38fdc31 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -1064,14 +1064,13 @@ Fold the fields. `use_foldl` controls whether this is done left-to-right (`true`) or right-to-left (`false`). */ pub fn cs_fold(use_foldl: bool, - f: &fn(@ExtCtxt, Span, - old: @Expr, - self_f: @Expr, - other_fs: &[@Expr]) -> @Expr, + f: |@ExtCtxt, Span, @Expr, @Expr, &[@Expr]| -> @Expr, base: @Expr, enum_nonmatch_f: EnumNonMatchFunc, - cx: @ExtCtxt, trait_span: Span, - substructure: &Substructure) -> @Expr { + cx: @ExtCtxt, + trait_span: Span, + substructure: &Substructure) + -> @Expr { match *substructure.fields { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { if use_foldl { @@ -1104,10 +1103,12 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1), ~~~ */ #[inline] -pub fn cs_same_method(f: &fn(@ExtCtxt, Span, ~[@Expr]) -> @Expr, +pub fn cs_same_method(f: |@ExtCtxt, Span, ~[@Expr]| -> @Expr, enum_nonmatch_f: EnumNonMatchFunc, - cx: @ExtCtxt, trait_span: Span, - substructure: &Substructure) -> @Expr { + cx: @ExtCtxt, + trait_span: Span, + substructure: &Substructure) + -> @Expr { match *substructure.fields { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { // call self_n.method(other_1_n, other_2_n, ...) @@ -1136,11 +1137,13 @@ fields. `use_foldl` controls whether this is done left-to-right */ #[inline] pub fn cs_same_method_fold(use_foldl: bool, - f: &fn(@ExtCtxt, Span, @Expr, @Expr) -> @Expr, + f: |@ExtCtxt, Span, @Expr, @Expr| -> @Expr, base: @Expr, enum_nonmatch_f: EnumNonMatchFunc, - cx: @ExtCtxt, trait_span: Span, - substructure: &Substructure) -> @Expr { + cx: @ExtCtxt, + trait_span: Span, + substructure: &Substructure) + -> @Expr { cs_same_method( |cx, span, vals| { if use_foldl { diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 2a16d0b025d..1877a6eb85b 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -128,10 +128,12 @@ fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { _ => cx.bug("Non-static method in `deriving(Rand)`") }; - fn rand_thing(cx: @ExtCtxt, span: Span, + fn rand_thing(cx: @ExtCtxt, + span: Span, ctor_ident: Ident, summary: &StaticFields, - rand_call: &fn(Span) -> @Expr) -> @Expr { + rand_call: |Span| -> @Expr) + -> @Expr { match *summary { Unnamed(ref fields) => { if fields.is_empty() { -- cgit 1.4.1-3-g733a5