@@ -131,13 +131,13 @@ pub enum Method<'a> {
131
131
///
132
132
/// The final element of this enum is the default "other" case which is
133
133
/// always required to be specified.
134
- Plural ( Option < uint > , ~ [ PluralArm < ' a > ] , ~ [ Piece < ' a > ] ) ,
134
+ Plural ( Option < uint > , Vec < PluralArm < ' a > > , Vec < Piece < ' a > > ) ,
135
135
136
136
/// A select method selects over a string. Each arm is a different string
137
137
/// which can be selected for.
138
138
///
139
139
/// As with `Plural`, a default "other" case is required as well.
140
- Select ( ~ [ SelectArm < ' a > ] , ~ [ Piece < ' a > ] ) ,
140
+ Select ( Vec < SelectArm < ' a > > , Vec < Piece < ' a > > ) ,
141
141
}
142
142
143
143
/// A selector for what pluralization a plural method should take
@@ -156,7 +156,7 @@ pub struct PluralArm<'a> {
156
156
/// literal.
157
157
pub selector : PluralSelector ,
158
158
/// Array of pieces which are the format of this arm
159
- pub result : ~ [ Piece < ' a > ] ,
159
+ pub result : Vec < Piece < ' a > > ,
160
160
}
161
161
162
162
/// Enum of the 5 CLDR plural keywords. There is one more, "other", but that
@@ -184,7 +184,7 @@ pub struct SelectArm<'a> {
184
184
/// String selector which guards this arm
185
185
pub selector : & ' a str ,
186
186
/// Array of pieces which are the format of this arm
187
- pub result : ~ [ Piece < ' a > ] ,
187
+ pub result : Vec < Piece < ' a > > ,
188
188
}
189
189
190
190
/// The parser structure for interpreting the input format string. This is
@@ -198,7 +198,7 @@ pub struct Parser<'a> {
198
198
cur : str:: CharOffsets < ' a > ,
199
199
depth : uint ,
200
200
/// Error messages accumulated during parsing
201
- pub errors : ~ [ ~ str ] ,
201
+ pub errors : Vec < ~ str > ,
202
202
}
203
203
204
204
impl < ' a > Iterator < Piece < ' a > > for Parser < ' a > {
@@ -236,7 +236,7 @@ impl<'a> Parser<'a> {
236
236
input : s,
237
237
cur : s. char_indices ( ) ,
238
238
depth : 0 ,
239
- errors : ~ [ ] ,
239
+ errors : vec ! ( ) ,
240
240
}
241
241
}
242
242
@@ -463,7 +463,7 @@ impl<'a> Parser<'a> {
463
463
/// Parses a 'select' statement (after the initial 'select' word)
464
464
fn select ( & mut self ) -> ~Method < ' a > {
465
465
let mut other = None ;
466
- let mut arms = ~ [ ] ;
466
+ let mut arms = vec ! ( ) ;
467
467
// Consume arms one at a time
468
468
loop {
469
469
self . ws ( ) ;
@@ -496,7 +496,7 @@ impl<'a> Parser<'a> {
496
496
Some ( arm) => { arm }
497
497
None => {
498
498
self . err ( "`select` statement must provide an `other` case" ) ;
499
- ~ [ ]
499
+ vec ! ( )
500
500
}
501
501
} ;
502
502
~Select ( arms, other)
@@ -506,7 +506,7 @@ impl<'a> Parser<'a> {
506
506
fn plural ( & mut self ) -> ~Method < ' a > {
507
507
let mut offset = None ;
508
508
let mut other = None ;
509
- let mut arms = ~ [ ] ;
509
+ let mut arms = vec ! ( ) ;
510
510
511
511
// First, attempt to parse the 'offset:' field. We know the set of
512
512
// selector words which can appear in plural arms, and the only ones
@@ -594,7 +594,7 @@ impl<'a> Parser<'a> {
594
594
Some ( arm) => { arm }
595
595
None => {
596
596
self . err ( "`plural` statement must provide an `other` case" ) ;
597
- ~ [ ]
597
+ vec ! ( )
598
598
}
599
599
} ;
600
600
~Plural ( offset, arms, other)
@@ -684,9 +684,9 @@ mod tests {
684
684
use super :: * ;
685
685
use prelude:: * ;
686
686
687
- fn same ( fmt : & ' static str , p : ~ [ Piece < ' static > ] ) {
687
+ fn same ( fmt : & ' static str , p : & [ Piece < ' static > ] ) {
688
688
let mut parser = Parser :: new ( fmt) ;
689
- assert ! ( p == parser. collect( ) ) ;
689
+ assert ! ( p == parser. collect:: < Vec < Piece < ' static >>> ( ) . as_slice ( ) ) ;
690
690
}
691
691
692
692
fn fmtdflt ( ) -> FormatSpec < ' static > {
@@ -708,12 +708,12 @@ mod tests {
708
708
709
709
#[ test]
710
710
fn simple ( ) {
711
- same ( "asdf" , ~ [ String ( "asdf" ) ] ) ;
712
- same ( "a\\ {b" , ~ [ String ( "a" ) , String ( "{b" ) ] ) ;
713
- same ( "a\\ #b" , ~ [ String ( "a" ) , String ( "#b" ) ] ) ;
714
- same ( "a\\ }b" , ~ [ String ( "a" ) , String ( "}b" ) ] ) ;
715
- same ( "a\\ }" , ~ [ String ( "a" ) , String ( "}" ) ] ) ;
716
- same ( "\\ }" , ~ [ String ( "}" ) ] ) ;
711
+ same ( "asdf" , [ String ( "asdf" ) ] ) ;
712
+ same ( "a\\ {b" , [ String ( "a" ) , String ( "{b" ) ] ) ;
713
+ same ( "a\\ #b" , [ String ( "a" ) , String ( "#b" ) ] ) ;
714
+ same ( "a\\ }b" , [ String ( "a" ) , String ( "}b" ) ] ) ;
715
+ same ( "a\\ }" , [ String ( "a" ) , String ( "}" ) ] ) ;
716
+ same ( "\\ }" , [ String ( "}" ) ] ) ;
717
717
}
718
718
719
719
#[ test] fn invalid01 ( ) { musterr ( "{" ) }
@@ -725,31 +725,31 @@ mod tests {
725
725
726
726
#[ test]
727
727
fn format_nothing ( ) {
728
- same ( "{}" , ~ [ Argument ( Argument {
728
+ same ( "{}" , [ Argument ( Argument {
729
729
position : ArgumentNext ,
730
730
format : fmtdflt ( ) ,
731
731
method : None ,
732
732
} ) ] ) ;
733
733
}
734
734
#[ test]
735
735
fn format_position ( ) {
736
- same ( "{3}" , ~ [ Argument ( Argument {
736
+ same ( "{3}" , [ Argument ( Argument {
737
737
position : ArgumentIs ( 3 ) ,
738
738
format : fmtdflt ( ) ,
739
739
method : None ,
740
740
} ) ] ) ;
741
741
}
742
742
#[ test]
743
743
fn format_position_nothing_else ( ) {
744
- same ( "{3:}" , ~ [ Argument ( Argument {
744
+ same ( "{3:}" , [ Argument ( Argument {
745
745
position : ArgumentIs ( 3 ) ,
746
746
format : fmtdflt ( ) ,
747
747
method : None ,
748
748
} ) ] ) ;
749
749
}
750
750
#[ test]
751
751
fn format_type ( ) {
752
- same ( "{3:a}" , ~ [ Argument ( Argument {
752
+ same ( "{3:a}" , [ Argument ( Argument {
753
753
position : ArgumentIs ( 3 ) ,
754
754
format : FormatSpec {
755
755
fill : None ,
@@ -764,7 +764,7 @@ mod tests {
764
764
}
765
765
#[ test]
766
766
fn format_align_fill ( ) {
767
- same ( "{3:>}" , ~ [ Argument ( Argument {
767
+ same ( "{3:>}" , [ Argument ( Argument {
768
768
position : ArgumentIs ( 3 ) ,
769
769
format : FormatSpec {
770
770
fill : None ,
@@ -776,7 +776,7 @@ mod tests {
776
776
} ,
777
777
method : None ,
778
778
} ) ] ) ;
779
- same ( "{3:0<}" , ~ [ Argument ( Argument {
779
+ same ( "{3:0<}" , [ Argument ( Argument {
780
780
position : ArgumentIs ( 3 ) ,
781
781
format : FormatSpec {
782
782
fill : Some ( '0' ) ,
@@ -788,7 +788,7 @@ mod tests {
788
788
} ,
789
789
method : None ,
790
790
} ) ] ) ;
791
- same ( "{3:*<abcd}" , ~ [ Argument ( Argument {
791
+ same ( "{3:*<abcd}" , [ Argument ( Argument {
792
792
position : ArgumentIs ( 3 ) ,
793
793
format : FormatSpec {
794
794
fill : Some ( '*' ) ,
@@ -803,7 +803,7 @@ mod tests {
803
803
}
804
804
#[ test]
805
805
fn format_counts ( ) {
806
- same ( "{:10s}" , ~ [ Argument ( Argument {
806
+ same ( "{:10s}" , [ Argument ( Argument {
807
807
position : ArgumentNext ,
808
808
format : FormatSpec {
809
809
fill : None ,
@@ -815,7 +815,7 @@ mod tests {
815
815
} ,
816
816
method : None ,
817
817
} ) ] ) ;
818
- same ( "{:10$.10s}" , ~ [ Argument ( Argument {
818
+ same ( "{:10$.10s}" , [ Argument ( Argument {
819
819
position : ArgumentNext ,
820
820
format : FormatSpec {
821
821
fill : None ,
@@ -827,7 +827,7 @@ mod tests {
827
827
} ,
828
828
method : None ,
829
829
} ) ] ) ;
830
- same ( "{:.*s}" , ~ [ Argument ( Argument {
830
+ same ( "{:.*s}" , [ Argument ( Argument {
831
831
position : ArgumentNext ,
832
832
format : FormatSpec {
833
833
fill : None ,
@@ -839,7 +839,7 @@ mod tests {
839
839
} ,
840
840
method : None ,
841
841
} ) ] ) ;
842
- same ( "{:.10$s}" , ~ [ Argument ( Argument {
842
+ same ( "{:.10$s}" , [ Argument ( Argument {
843
843
position : ArgumentNext ,
844
844
format : FormatSpec {
845
845
fill : None ,
@@ -851,7 +851,7 @@ mod tests {
851
851
} ,
852
852
method : None ,
853
853
} ) ] ) ;
854
- same ( "{:a$.b$s}" , ~ [ Argument ( Argument {
854
+ same ( "{:a$.b$s}" , [ Argument ( Argument {
855
855
position : ArgumentNext ,
856
856
format : FormatSpec {
857
857
fill : None ,
@@ -866,7 +866,7 @@ mod tests {
866
866
}
867
867
#[ test]
868
868
fn format_flags ( ) {
869
- same ( "{:-}" , ~ [ Argument ( Argument {
869
+ same ( "{:-}" , [ Argument ( Argument {
870
870
position : ArgumentNext ,
871
871
format : FormatSpec {
872
872
fill : None ,
@@ -878,7 +878,7 @@ mod tests {
878
878
} ,
879
879
method : None ,
880
880
} ) ] ) ;
881
- same ( "{:+#}" , ~ [ Argument ( Argument {
881
+ same ( "{:+#}" , [ Argument ( Argument {
882
882
position : ArgumentNext ,
883
883
format : FormatSpec {
884
884
fill : None ,
@@ -893,7 +893,7 @@ mod tests {
893
893
}
894
894
#[ test]
895
895
fn format_mixture ( ) {
896
- same ( "abcd {3:a} efg" , ~ [ String ( "abcd " ) , Argument ( Argument {
896
+ same ( "abcd {3:a} efg" , [ String ( "abcd " ) , Argument ( Argument {
897
897
position : ArgumentIs ( 3 ) ,
898
898
format : FormatSpec {
899
899
fill : None ,
@@ -909,42 +909,42 @@ mod tests {
909
909
910
910
#[ test]
911
911
fn select_simple ( ) {
912
- same ( "{, select, other { haha } }" , ~ [ Argument ( Argument {
912
+ same ( "{, select, other { haha } }" , [ Argument ( Argument {
913
913
position : ArgumentNext ,
914
914
format : fmtdflt ( ) ,
915
- method : Some ( ~Select ( ~ [ ] , ~ [ String ( " haha " ) ] ) )
915
+ method : Some ( ~Select ( vec ! [ ] , vec ! [ String ( " haha " ) ] ) )
916
916
} ) ] ) ;
917
- same ( "{1, select, other { haha } }" , ~ [ Argument ( Argument {
917
+ same ( "{1, select, other { haha } }" , [ Argument ( Argument {
918
918
position : ArgumentIs ( 1 ) ,
919
919
format : fmtdflt ( ) ,
920
- method : Some ( ~Select ( ~ [ ] , ~ [ String ( " haha " ) ] ) )
920
+ method : Some ( ~Select ( vec ! [ ] , vec ! [ String ( " haha " ) ] ) )
921
921
} ) ] ) ;
922
- same ( "{1, select, other {#} }" , ~ [ Argument ( Argument {
922
+ same ( "{1, select, other {#} }" , [ Argument ( Argument {
923
923
position : ArgumentIs ( 1 ) ,
924
924
format : fmtdflt ( ) ,
925
- method : Some ( ~Select ( ~ [ ] , ~ [ CurrentArgument ] ) )
925
+ method : Some ( ~Select ( vec ! [ ] , vec ! [ CurrentArgument ] ) )
926
926
} ) ] ) ;
927
- same ( "{1, select, other {{2, select, other {lol}}} }" , ~ [ Argument ( Argument {
927
+ same ( "{1, select, other {{2, select, other {lol}}} }" , [ Argument ( Argument {
928
928
position : ArgumentIs ( 1 ) ,
929
929
format : fmtdflt ( ) ,
930
- method : Some ( ~Select ( ~ [ ] , ~ [ Argument ( Argument {
930
+ method : Some ( ~Select ( vec ! [ ] , vec ! [ Argument ( Argument {
931
931
position: ArgumentIs ( 2 ) ,
932
932
format: fmtdflt( ) ,
933
- method : Some ( ~Select ( ~ [ ] , ~ [ String ( "lol" ) ] ) )
933
+ method: Some ( ~Select ( vec! [ ] , vec! [ String ( "lol" ) ] ) )
934
934
} ) ] ) ) // wat
935
935
} ) ] ) ;
936
936
}
937
937
938
938
#[ test]
939
939
fn select_cases ( ) {
940
- same ( "{1, select, a{1} b{2} c{3} other{4} }" , ~ [ Argument ( Argument {
940
+ same ( "{1, select, a{1} b{2} c{3} other{4} }" , [ Argument ( Argument {
941
941
position : ArgumentIs ( 1 ) ,
942
942
format : fmtdflt ( ) ,
943
- method : Some ( ~Select ( ~ [
944
- SelectArm { selector : "a" , result : ~ [ String ( "1" ) ] } ,
945
- SelectArm { selector : "b" , result : ~ [ String ( "2" ) ] } ,
946
- SelectArm { selector : "c" , result : ~ [ String ( "3" ) ] } ,
947
- ] , ~ [ String ( "4" ) ] ) )
943
+ method : Some ( ~Select ( vec ! [
944
+ SelectArm { selector: "a" , result: vec! [ String ( "1" ) ] } ,
945
+ SelectArm { selector: "b" , result: vec! [ String ( "2" ) ] } ,
946
+ SelectArm { selector: "c" , result: vec! [ String ( "3" ) ] } ,
947
+ ] , vec ! [ String ( "4" ) ] ) )
948
948
} ) ] ) ;
949
949
}
950
950
@@ -961,25 +961,25 @@ mod tests {
961
961
962
962
#[ test]
963
963
fn plural_simple ( ) {
964
- same ( "{, plural, other { haha } }" , ~ [ Argument ( Argument {
964
+ same ( "{, plural, other { haha } }" , [ Argument ( Argument {
965
965
position : ArgumentNext ,
966
966
format : fmtdflt ( ) ,
967
- method : Some ( ~Plural ( None , ~ [ ] , ~ [ String ( " haha " ) ] ) )
967
+ method : Some ( ~Plural ( None , vec ! [ ] , vec ! [ String ( " haha " ) ] ) )
968
968
} ) ] ) ;
969
- same ( "{:, plural, other { haha } }" , ~ [ Argument ( Argument {
969
+ same ( "{:, plural, other { haha } }" , [ Argument ( Argument {
970
970
position : ArgumentNext ,
971
971
format : fmtdflt ( ) ,
972
- method : Some ( ~Plural ( None , ~ [ ] , ~ [ String ( " haha " ) ] ) )
972
+ method : Some ( ~Plural ( None , vec ! [ ] , vec ! [ String ( " haha " ) ] ) )
973
973
} ) ] ) ;
974
974
same ( "{, plural, offset:1 =2{2} =3{3} many{yes} other{haha} }" ,
975
- ~ [ Argument ( Argument {
975
+ [ Argument ( Argument {
976
976
position : ArgumentNext ,
977
977
format : fmtdflt ( ) ,
978
- method : Some ( ~Plural ( Some ( 1 ) , ~ [
979
- PluralArm { selector : Literal ( 2 ) , result : ~ [ String ( "2" ) ] } ,
980
- PluralArm { selector : Literal ( 3 ) , result : ~ [ String ( "3" ) ] } ,
981
- PluralArm { selector : Keyword ( Many ) , result : ~ [ String ( "yes" ) ] }
982
- ] , ~ [ String ( "haha" ) ] ) )
978
+ method : Some ( ~Plural ( Some ( 1 ) , vec ! [
979
+ PluralArm { selector: Literal ( 2 ) , result: vec! [ String ( "2" ) ] } ,
980
+ PluralArm { selector: Literal ( 3 ) , result: vec! [ String ( "3" ) ] } ,
981
+ PluralArm { selector: Keyword ( Many ) , result: vec! [ String ( "yes" ) ] }
982
+ ] , vec ! [ String ( "haha" ) ] ) )
983
983
} ) ] ) ;
984
984
}
985
985
}
0 commit comments