@@ -30,7 +30,7 @@ impl Module<Id> {
30
30
}
31
31
}
32
32
33
- #[ deriving ( Clone , PartialEq ) ]
33
+ #[ derive ( Clone , PartialEq ) ]
34
34
pub struct Class < Ident > {
35
35
pub constraints : Vec < Constraint < Name > > ,
36
36
pub name : Name ,
@@ -39,43 +39,43 @@ pub struct Class<Ident> {
39
39
pub bindings : Vec < Binding < Ident > >
40
40
}
41
41
42
- #[ deriving ( Clone ) ]
42
+ #[ derive ( Clone ) ]
43
43
pub struct Instance < Ident = InternedStr > {
44
44
pub bindings : Vec < Binding < Ident > > ,
45
45
pub constraints : Vec < Constraint < Name > > ,
46
46
pub typ : Type ,
47
47
pub classname : Name
48
48
}
49
49
50
- #[ deriving ( Clone , PartialEq ) ]
50
+ #[ derive ( Clone , PartialEq ) ]
51
51
pub struct Binding < Ident > {
52
52
pub name : Ident ,
53
53
pub expression : Expr < Ident >
54
54
}
55
55
56
- #[ deriving ( Clone , PartialEq ) ]
56
+ #[ derive ( Clone , PartialEq ) ]
57
57
pub struct Alternative < Ident > {
58
58
pub pattern : Pattern < Ident > ,
59
59
pub expression : Expr < Ident >
60
60
}
61
61
62
- #[ deriving ( Clone , PartialEq ) ]
62
+ #[ derive ( Clone , PartialEq ) ]
63
63
pub enum Pattern < Ident > {
64
64
Constructor ( Ident , Vec < Ident > ) ,
65
65
Identifier ( Ident ) ,
66
66
Number ( int ) ,
67
67
WildCard
68
68
}
69
69
70
- #[ deriving ( Clone , PartialEq ) ]
70
+ #[ derive ( Clone , PartialEq ) ]
71
71
pub struct LiteralData {
72
72
pub typ : Type ,
73
73
pub value : Literal_
74
74
}
75
75
76
76
pub type Literal_ = module:: LiteralData ;
77
77
78
- #[ deriving ( Clone , PartialEq ) ]
78
+ #[ derive ( Clone , PartialEq ) ]
79
79
pub enum Expr < Ident > {
80
80
Identifier ( Ident ) ,
81
81
Apply ( Box < Expr < Ident > > , Box < Expr < Ident > > ) ,
@@ -165,7 +165,7 @@ impl PartialEq<str> for Name {
165
165
}
166
166
167
167
///Id is a Name combined with a type
168
- #[ deriving ( PartialEq , Eq , Hash , Clone ) ]
168
+ #[ derive ( PartialEq , Eq , Hash , Clone ) ]
169
169
pub struct Id < T = Name > {
170
170
pub name : T ,
171
171
pub typ : Qualified < Type , Name >
@@ -279,7 +279,7 @@ pub mod mutable {
279
279
}
280
280
281
281
pub fn walk_module < Ident , V : Visitor < Ident > > ( visitor : & mut V , module : & mut Module < Ident > ) {
282
- for bind in module. bindings . mut_iter ( ) {
282
+ for bind in module. bindings . iter_mut ( ) {
283
283
visitor. visit_binding ( bind) ;
284
284
}
285
285
}
@@ -296,14 +296,14 @@ pub mod mutable {
296
296
}
297
297
& Lambda ( _, ref mut body) => visitor. visit_expr ( * body) ,
298
298
& Let ( ref mut binds, ref mut e) => {
299
- for b in binds. mut_iter ( ) {
299
+ for b in binds. iter_mut ( ) {
300
300
visitor. visit_binding ( b) ;
301
301
}
302
302
visitor. visit_expr ( * e) ;
303
303
}
304
304
& Case ( ref mut e, ref mut alts) => {
305
305
visitor. visit_expr ( * e) ;
306
- for alt in alts. mut_iter ( ) {
306
+ for alt in alts. iter_mut ( ) {
307
307
visitor. visit_alternative ( alt) ;
308
308
}
309
309
}
@@ -343,7 +343,7 @@ pub mod result {
343
343
pub fn walk_module < Ident > ( visitor : & mut Visitor < Ident > , mut module : Module < Ident > ) -> Module < Ident > {
344
344
let mut bindings = vec ! [ ] ;
345
345
:: std:: mem:: swap ( & mut module. bindings , & mut bindings) ;
346
- module. bindings = bindings. move_iter ( )
346
+ module. bindings = bindings. into_iter ( )
347
347
. map ( |bind| visitor. visit_binding ( bind) )
348
348
. collect ( ) ;
349
349
module
@@ -366,14 +366,14 @@ pub mod result {
366
366
}
367
367
Lambda ( x, body) => Lambda ( x, box visitor. visit_expr ( * body) ) ,
368
368
Let ( binds, e) => {
369
- let bs: Vec < Binding < Ident > > = binds. move_iter ( ) . map ( |b| {
369
+ let bs: Vec < Binding < Ident > > = binds. into_iter ( ) . map ( |b| {
370
370
visitor. visit_binding ( b)
371
371
} ) . collect ( ) ;
372
372
Let ( bs, box visitor. visit_expr ( * e) )
373
373
}
374
374
Case ( e, alts) => {
375
375
let e2 = visitor. visit_expr ( * e) ;
376
- let alts2: Vec < Alternative < Ident > > = alts. move_iter ( )
376
+ let alts2: Vec < Alternative < Ident > > = alts. into_iter ( )
377
377
. map ( |alt| visitor. visit_alternative ( alt) )
378
378
. collect ( ) ;
379
379
Case ( box e2, alts2)
@@ -404,7 +404,7 @@ pub mod translate {
404
404
functions_in_class : & ' a mut ( FnMut ( Name ) -> ( & ' a TypeVariable , & ' a [ TypeDeclaration < Name > ] ) + ' a )
405
405
}
406
406
407
- #[ deriving ( Show ) ]
407
+ #[ derive ( Show ) ]
408
408
struct Equation < ' a > ( & ' a [ ( Id < Name > , Pattern < Id < Name > > ) ] , ( & ' a [ Binding < Id < Name > > ] , & ' a module:: Match < Name > ) ) ;
409
409
410
410
pub fn translate_expr ( expr : module:: TypedExpr < Name > ) -> Expr < Id < Name > > {
@@ -424,7 +424,7 @@ pub mod translate {
424
424
( var, decls. as_slice ( ) )
425
425
}
426
426
} ;
427
- modules. move_iter ( )
427
+ modules. into_iter ( )
428
428
. map ( |module| translate_module_ ( & mut translator, module) )
429
429
. collect ( )
430
430
}
@@ -445,7 +445,7 @@ pub mod translate {
445
445
446
446
let mut new_instances: Vec < Instance < Id < Name > > > = Vec :: new ( ) ;
447
447
448
- let classes2 : Vec < Class < Id > > = classes. move_iter ( ) . map ( |class| {
448
+ let classes2 : Vec < Class < Id > > = classes. into_iter ( ) . map ( |class| {
449
449
let module:: Class {
450
450
constraints : cs,
451
451
name : name,
@@ -462,31 +462,31 @@ pub mod translate {
462
462
}
463
463
} ) . collect ( ) ;
464
464
465
- for instance in instances. move_iter ( ) {
465
+ for instance in instances. into_iter ( ) {
466
466
let module:: Instance {
467
467
classname : classname,
468
468
typ : instance_type,
469
469
constraints : constraints,
470
470
bindings : bindings
471
471
} = instance;
472
- let bs: Vec < Binding < Id < Name > > > = translator. translate_bindings ( bindings) . move_iter ( ) . collect ( ) ;
472
+ let bs: Vec < Binding < Id < Name > > > = translator. translate_bindings ( bindings) . into_iter ( ) . collect ( ) ;
473
473
new_instances. push ( Instance {
474
474
constraints : constraints,
475
475
typ : instance_type,
476
476
classname : classname,
477
477
bindings : bs
478
478
} ) ;
479
479
}
480
- let bs: Vec < Binding < Id < Name > > > = translator. translate_bindings ( bindings) . move_iter ( ) . collect ( ) ;
480
+ let bs: Vec < Binding < Id < Name > > > = translator. translate_bindings ( bindings) . into_iter ( ) . collect ( ) ;
481
481
for data in dataDefinitions. iter ( ) {
482
482
generate_deriving ( & mut new_instances, data) ;
483
483
}
484
- for instance in new_instances. mut_iter ( ) {
484
+ for instance in new_instances. iter_mut ( ) {
485
485
let ( class_var, class_decls) = ( translator. functions_in_class ) ( instance. classname ) ;
486
486
let defaults = create_default_stubs ( class_var, class_decls, instance) ;
487
487
let mut temp = box [ ] ;
488
488
:: std:: mem:: swap ( & mut temp, & mut instance. bindings ) ;
489
- let vec: Vec < Binding < Id < Name > > > = temp. move_iter ( ) . chain ( defaults. move_iter ( ) ) . collect ( ) ;
489
+ let vec: Vec < Binding < Id < Name > > > = temp. into_iter ( ) . chain ( defaults. into_iter ( ) ) . collect ( ) ;
490
490
instance. bindings = vec;
491
491
}
492
492
Module {
@@ -511,7 +511,7 @@ pub mod translate {
511
511
{
512
512
let context = :: std:: mem:: replace ( & mut typ. constraints , box [ ] ) ;
513
513
//Remove all constraints which refer to the class's variable
514
- let vec_context: Vec < Constraint < Name > > = context. move_iter ( )
514
+ let vec_context: Vec < Constraint < Name > > = context. into_iter ( )
515
515
. filter ( |c| c. variables [ 0 ] != * class_var)
516
516
. collect ( ) ;
517
517
typ. constraints = vec_context;
@@ -604,7 +604,7 @@ impl <'a> Translator<'a> {
604
604
}
605
605
module:: Expr :: Do ( bindings, expr) => {
606
606
let mut result = self . translate_expr ( * expr) ;
607
- for bind in bindings. move_iter ( ) . rev ( ) {
607
+ for bind in bindings. into_iter ( ) . rev ( ) {
608
608
result = match bind {
609
609
module:: DoBinding :: DoExpr ( e) => {
610
610
let core = self . translate_expr ( e) ;
@@ -669,13 +669,13 @@ impl <'a> Translator<'a> {
669
669
, Alternative { pattern: Pattern :: WildCard , expression: Apply ( box fail_ident, box string( "Unmatched pattern in let" ) ) } ] ) ) ;
670
670
let bind = Binding { name : func_ident. clone ( ) , expression : func } ;
671
671
672
- Let ( vec ! [ bind] , box apply ( bind_ident, ( vec ! [ expr, Identifier ( func_ident) ] ) . move_iter ( ) ) )
672
+ Let ( vec ! [ bind] , box apply ( bind_ident, ( vec ! [ expr, Identifier ( func_ident) ] ) . into_iter ( ) ) )
673
673
}
674
674
675
675
fn translate_bindings ( & mut self , bindings : Vec < module:: Binding < Name > > ) -> Vec < Binding < Id < Name > > > {
676
676
let mut result = Vec :: new ( ) ;
677
677
let mut vec: Vec < module:: Binding < Name > > = Vec :: new ( ) ;
678
- for bind in bindings. move_iter ( ) {
678
+ for bind in bindings. into_iter ( ) {
679
679
if vec. len ( ) > 0 && vec. get ( 0 ) . name != bind. name {
680
680
result. push ( self . translate_matching_groups ( vec) ) ;
681
681
vec = Vec :: new ( ) ;
@@ -695,7 +695,7 @@ impl <'a> Translator<'a> {
695
695
let mut name = :: std:: string:: String :: from_str ( id. name . name . as_slice ( ) ) ;
696
696
let base_length = name. len ( ) ;
697
697
result. push ( ( id, Pattern :: Number ( 0 ) ) ) ; //Dummy
698
- for ( i, p) in patterns. mut_iter ( ) . enumerate ( ) {
698
+ for ( i, p) in patterns. iter_mut ( ) . enumerate ( ) {
699
699
let x = match * p {
700
700
module:: Pattern :: Constructor ( ..) | module:: Pattern :: Number ( ..) => {
701
701
//HACK, by making the variable have the same uid as
@@ -744,7 +744,7 @@ impl <'a> Translator<'a> {
744
744
let mut vec = Vec :: new ( ) ;
745
745
let dummy_var = [ Id :: new ( self . name_supply . anonymous ( ) , Type :: new_var ( intern ( "a" ) ) , vec ! [ ] ) ] ;
746
746
let uid = self . name_supply . next_id ( ) ;
747
- for module:: Alternative { pattern : pattern, matches : matches, where_bindings : where_bindings } in alts. move_iter ( ) {
747
+ for module:: Alternative { pattern : pattern, matches : matches, where_bindings : where_bindings } in alts. into_iter ( ) {
748
748
let bindings = where_bindings. map_or ( box [ ] , |bs| self . translate_bindings ( bs) ) ;
749
749
vec. push ( ( self . unwrap_patterns ( uid, dummy_var, [ pattern. node ] ) , bindings, matches) ) ;
750
750
}
@@ -770,7 +770,7 @@ impl <'a> Translator<'a> {
770
770
typ : module:: Qualified { constraints : constraints, value : typ, } ,
771
771
where_bindings : where_bindings
772
772
} = bindings. pop ( ) . unwrap ( ) ;
773
- let arg_iterator = arguments. move_iter ( ) . map ( |p| {
773
+ let arg_iterator = arguments. into_iter ( ) . map ( |p| {
774
774
match p {
775
775
module:: Pattern :: Identifier ( n) => n,
776
776
module:: Pattern :: WildCard => Name { name : intern ( "_" ) , uid : -1 } ,
@@ -783,7 +783,7 @@ impl <'a> Translator<'a> {
783
783
. map ( |( typ, arg) | {
784
784
Id :: new ( arg, typ. clone ( ) , vec ! [ ] )
785
785
} ) ;
786
- let where_bindings_binds = where_bindings. map_or ( Vec :: new ( ) , |bs| self . translate_bindings ( bs) . move_iter ( ) . collect ( ) ) ;
786
+ let where_bindings_binds = where_bindings. map_or ( Vec :: new ( ) , |bs| self . translate_bindings ( bs) . into_iter ( ) . collect ( ) ) ;
787
787
make_lambda ( lambda_ids, make_let ( where_bindings_binds, self . translate_match ( matches) ) )
788
788
} ;
789
789
return Binding {
@@ -810,7 +810,7 @@ impl <'a> Translator<'a> {
810
810
//First we flatten all the patterns that occur in each equation
811
811
//(2:xs) -> [(x:xs), 2]
812
812
let uid = self . name_supply . next_id ( ) ;
813
- let equations: Vec < _ > = bindings. move_iter ( ) . map ( |bind| {
813
+ let equations: Vec < _ > = bindings. into_iter ( ) . map ( |bind| {
814
814
let module:: Binding {
815
815
arguments : arguments,
816
816
matches : matches,
@@ -821,7 +821,7 @@ impl <'a> Translator<'a> {
821
821
( self . unwrap_patterns ( uid, arg_ids. as_slice ( ) , arguments) , where_bindings_binds, matches)
822
822
} ) . collect ( ) ;
823
823
let mut expr = self . translate_equations_ ( equations) ;
824
- expr = make_lambda ( arg_ids. move_iter ( ) , expr) ;
824
+ expr = make_lambda ( arg_ids. into_iter ( ) , expr) ;
825
825
debug ! ( "Desugared {} :: {}\n {}" , name. name, name. typ, expr) ;
826
826
Binding {
827
827
name : name,
@@ -1004,7 +1004,7 @@ impl <'a> Translator<'a> {
1004
1004
module:: Pattern :: Identifier ( i) => Pattern :: Identifier ( Id :: new ( i, Type :: new_var ( intern ( "a" ) ) , vec ! [ ] ) ) ,
1005
1005
module:: Pattern :: Number ( n) => Pattern :: Number ( n) ,
1006
1006
module:: Pattern :: Constructor ( name, patterns) => {
1007
- let ps = patterns. move_iter ( ) . map ( |pat| {
1007
+ let ps = patterns. into_iter ( ) . map ( |pat| {
1008
1008
match pat {
1009
1009
module:: Pattern :: Identifier ( name) => Id :: new ( name, Type :: new_var ( intern ( "a" ) ) , vec ! [ ] ) ,
1010
1010
module:: Pattern :: WildCard => Id :: new ( Name { name : intern ( "_" ) , uid : -1 } , Type :: new_var ( intern ( "a" ) ) , vec ! [ ] ) ,
0 commit comments