@@ -589,7 +589,7 @@ impl<'self> MethodDef<'self> {
589
589
590
590
// transpose raw_fields
591
591
let fields = match raw_fields {
592
- [ self_arg, .. rest] => {
592
+ [ ref self_arg, .. rest] => {
593
593
do self_arg. iter ( ) . enumerate ( ) . transform |( i, & ( opt_id, field) ) | {
594
594
let other_fields = do rest. map |l| {
595
595
match & l[ i] {
@@ -738,16 +738,20 @@ impl<'self> MethodDef<'self> {
738
738
739
739
let mut enum_matching_fields = vec:: from_elem( self_vec. len( ) , ~[ ] ) ;
740
740
741
- for matches_so_far. tail( ) . iter( ) . advance |& ( _, _, other_fields) | {
742
- for other_fields. iter( ) . enumerate( ) . advance |( i, & ( _, other_field) ) | {
743
- enum_matching_fields[ i] . push( other_field) ;
741
+ for matches_so_far. tail( ) . iter( ) . advance |triple| {
742
+ match triple {
743
+ & ( _, _, ref other_fields) => {
744
+ for other_fields. iter( ) . enumerate( ) . advance |( i, pair) | {
745
+ enum_matching_fields[ i] . push( pair. second( ) ) ;
746
+ }
747
+ }
744
748
}
745
749
}
746
750
let field_tuples =
747
751
do self_vec. iter( )
748
752
. zip( enum_matching_fields. iter( ) )
749
- . transform |( & ( id, self_f) , & other) | {
750
- ( id, self_f, other)
753
+ . transform |( & ( id, self_f) , other) | {
754
+ ( id, self_f, copy * other)
751
755
} . collect( ) ;
752
756
substructure = EnumMatching ( variant_index, variant, field_tuples) ;
753
757
}
@@ -1015,19 +1019,22 @@ left-to-right (`true`) or right-to-left (`false`).
1015
1019
pub fn cs_fold ( use_foldl : bool ,
1016
1020
f : & fn ( @ExtCtxt , span ,
1017
1021
old: @expr,
1018
- self_f: @expr, other_fs: & [ @expr] ) -> @expr,
1022
+ self_f: @expr,
1023
+ other_fs: & [ @expr] ) -> @expr,
1019
1024
base: @expr,
1020
1025
enum_nonmatch_f : EnumNonMatchFunc ,
1021
1026
cx : @ExtCtxt , span : span ,
1022
1027
substructure : & Substructure ) -> @expr {
1023
1028
match * substructure. fields {
1024
1029
EnumMatching ( _, _, ref all_fields) | Struct ( ref all_fields) => {
1025
1030
if use_foldl {
1026
- do all_fields. iter ( ) . fold ( base) |old, & ( _, self_f, other_fs) | {
1031
+ do all_fields. iter ( ) . fold ( base) |old, triple| {
1032
+ let ( _, self_f, other_fs) = copy * triple;
1027
1033
f ( cx, span, old, self_f, other_fs)
1028
1034
}
1029
1035
} else {
1030
- do all_fields. rev_iter ( ) . fold ( base) |old, & ( _, self_f, other_fs) | {
1036
+ do all_fields. rev_iter ( ) . fold ( base) |old, triple| {
1037
+ let ( _, self_f, other_fs) = copy * triple;
1031
1038
f ( cx, span, old, self_f, other_fs)
1032
1039
}
1033
1040
}
@@ -1059,7 +1066,8 @@ pub fn cs_same_method(f: &fn(@ExtCtxt, span, ~[@expr]) -> @expr,
1059
1066
match * substructure. fields {
1060
1067
EnumMatching ( _, _, ref all_fields) | Struct ( ref all_fields) => {
1061
1068
// call self_n.method(other_1_n, other_2_n, ...)
1062
- let called = do all_fields. map |& ( _, self_field, other_fields) | {
1069
+ let called = do all_fields. map |triple| {
1070
+ let ( _, self_field, other_fields) = copy * triple;
1063
1071
cx. expr_method_call ( span,
1064
1072
self_field,
1065
1073
substructure. method_ident ,
0 commit comments