libsyntax: Change all uses of &fn to ||.
This commit is contained in:
parent
18a30aff45
commit
492677ec1e
16 changed files with 139 additions and 111 deletions
|
|
@ -559,11 +559,11 @@ impl <K: Eq + Hash + IterBytes + 'static, V: 'static> MapChain<K,V>{
|
|||
// 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 <K: Eq + Hash + IterBytes + 'static, V: 'static> MapChain<K,V>{
|
|||
// ... 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 <K: Eq + Hash + IterBytes + 'static, V: 'static> MapChain<K,V>{
|
|||
}
|
||||
|
||||
// returns true if the binding for 'n' satisfies 'pred' in 'map'
|
||||
fn satisfies_pred<K : Eq + Hash + IterBytes,V>(map : &mut HashMap<K,V>,
|
||||
n: &K,
|
||||
pred: &fn(&V)->bool)
|
||||
-> bool {
|
||||
fn satisfies_pred<K:Eq + Hash + IterBytes,
|
||||
V>(
|
||||
map: &mut HashMap<K,V>,
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue