@@ -131,13 +131,13 @@ pub enum Method<'a> {
131131 ///
132132 /// The final element of this enum is the default "other" case which is
133133 /// always required to be specified.
134- Plural ( Option < uint > , ~ [ PluralArm < ' a > ] , ~ [ Piece < ' a > ] ) ,
134+ Plural ( Option < uint > , Vec < PluralArm < ' a > > , Vec < Piece < ' a > > ) ,
135135
136136 /// A select method selects over a string. Each arm is a different string
137137 /// which can be selected for.
138138 ///
139139 /// 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 > > ) ,
141141}
142142
143143/// A selector for what pluralization a plural method should take
@@ -156,7 +156,7 @@ pub struct PluralArm<'a> {
156156 /// literal.
157157 pub selector : PluralSelector ,
158158 /// Array of pieces which are the format of this arm
159- pub result : ~ [ Piece < ' a > ] ,
159+ pub result : Vec < Piece < ' a > > ,
160160}
161161
162162/// Enum of the 5 CLDR plural keywords. There is one more, "other", but that
@@ -184,7 +184,7 @@ pub struct SelectArm<'a> {
184184 /// String selector which guards this arm
185185 pub selector : & ' a str ,
186186 /// Array of pieces which are the format of this arm
187- pub result : ~ [ Piece < ' a > ] ,
187+ pub result : Vec < Piece < ' a > > ,
188188}
189189
190190/// The parser structure for interpreting the input format string. This is
@@ -198,7 +198,7 @@ pub struct Parser<'a> {
198198 cur : str:: CharOffsets < ' a > ,
199199 depth : uint ,
200200 /// Error messages accumulated during parsing
201- pub errors : ~ [ ~ str ] ,
201+ pub errors : Vec < ~ str > ,
202202}
203203
204204impl < ' a > Iterator < Piece < ' a > > for Parser < ' a > {
@@ -236,7 +236,7 @@ impl<'a> Parser<'a> {
236236 input : s,
237237 cur : s. char_indices ( ) ,
238238 depth : 0 ,
239- errors : ~ [ ] ,
239+ errors : vec ! ( ) ,
240240 }
241241 }
242242
@@ -463,7 +463,7 @@ impl<'a> Parser<'a> {
463463 /// Parses a 'select' statement (after the initial 'select' word)
464464 fn select ( & mut self ) -> ~Method < ' a > {
465465 let mut other = None ;
466- let mut arms = ~ [ ] ;
466+ let mut arms = vec ! ( ) ;
467467 // Consume arms one at a time
468468 loop {
469469 self . ws ( ) ;
@@ -496,7 +496,7 @@ impl<'a> Parser<'a> {
496496 Some ( arm) => { arm }
497497 None => {
498498 self . err ( "`select` statement must provide an `other` case" ) ;
499- ~ [ ]
499+ vec ! ( )
500500 }
501501 } ;
502502 ~Select ( arms, other)
@@ -506,7 +506,7 @@ impl<'a> Parser<'a> {
506506 fn plural ( & mut self ) -> ~Method < ' a > {
507507 let mut offset = None ;
508508 let mut other = None ;
509- let mut arms = ~ [ ] ;
509+ let mut arms = vec ! ( ) ;
510510
511511 // First, attempt to parse the 'offset:' field. We know the set of
512512 // selector words which can appear in plural arms, and the only ones
@@ -594,7 +594,7 @@ impl<'a> Parser<'a> {
594594 Some ( arm) => { arm }
595595 None => {
596596 self . err ( "`plural` statement must provide an `other` case" ) ;
597- ~ [ ]
597+ vec ! ( )
598598 }
599599 } ;
600600 ~Plural ( offset, arms, other)
@@ -684,9 +684,9 @@ mod tests {
684684 use super :: * ;
685685 use prelude:: * ;
686686
687- fn same ( fmt : & ' static str , p : ~ [ Piece < ' static > ] ) {
687+ fn same ( fmt : & ' static str , p : & [ Piece < ' static > ] ) {
688688 let mut parser = Parser :: new ( fmt) ;
689- assert ! ( p == parser. collect( ) ) ;
689+ assert ! ( p == parser. collect:: < Vec < Piece < ' static >>> ( ) . as_slice ( ) ) ;
690690 }
691691
692692 fn fmtdflt ( ) -> FormatSpec < ' static > {
@@ -708,12 +708,12 @@ mod tests {
708708
709709 #[ test]
710710 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 ( "}" ) ] ) ;
717717 }
718718
719719 #[ test] fn invalid01 ( ) { musterr ( "{" ) }
@@ -725,31 +725,31 @@ mod tests {
725725
726726 #[ test]
727727 fn format_nothing ( ) {
728- same ( "{}" , ~ [ Argument ( Argument {
728+ same ( "{}" , [ Argument ( Argument {
729729 position : ArgumentNext ,
730730 format : fmtdflt ( ) ,
731731 method : None ,
732732 } ) ] ) ;
733733 }
734734 #[ test]
735735 fn format_position ( ) {
736- same ( "{3}" , ~ [ Argument ( Argument {
736+ same ( "{3}" , [ Argument ( Argument {
737737 position : ArgumentIs ( 3 ) ,
738738 format : fmtdflt ( ) ,
739739 method : None ,
740740 } ) ] ) ;
741741 }
742742 #[ test]
743743 fn format_position_nothing_else ( ) {
744- same ( "{3:}" , ~ [ Argument ( Argument {
744+ same ( "{3:}" , [ Argument ( Argument {
745745 position : ArgumentIs ( 3 ) ,
746746 format : fmtdflt ( ) ,
747747 method : None ,
748748 } ) ] ) ;
749749 }
750750 #[ test]
751751 fn format_type ( ) {
752- same ( "{3:a}" , ~ [ Argument ( Argument {
752+ same ( "{3:a}" , [ Argument ( Argument {
753753 position : ArgumentIs ( 3 ) ,
754754 format : FormatSpec {
755755 fill : None ,
@@ -764,7 +764,7 @@ mod tests {
764764 }
765765 #[ test]
766766 fn format_align_fill ( ) {
767- same ( "{3:>}" , ~ [ Argument ( Argument {
767+ same ( "{3:>}" , [ Argument ( Argument {
768768 position : ArgumentIs ( 3 ) ,
769769 format : FormatSpec {
770770 fill : None ,
@@ -776,7 +776,7 @@ mod tests {
776776 } ,
777777 method : None ,
778778 } ) ] ) ;
779- same ( "{3:0<}" , ~ [ Argument ( Argument {
779+ same ( "{3:0<}" , [ Argument ( Argument {
780780 position : ArgumentIs ( 3 ) ,
781781 format : FormatSpec {
782782 fill : Some ( '0' ) ,
@@ -788,7 +788,7 @@ mod tests {
788788 } ,
789789 method : None ,
790790 } ) ] ) ;
791- same ( "{3:*<abcd}" , ~ [ Argument ( Argument {
791+ same ( "{3:*<abcd}" , [ Argument ( Argument {
792792 position : ArgumentIs ( 3 ) ,
793793 format : FormatSpec {
794794 fill : Some ( '*' ) ,
@@ -803,7 +803,7 @@ mod tests {
803803 }
804804 #[ test]
805805 fn format_counts ( ) {
806- same ( "{:10s}" , ~ [ Argument ( Argument {
806+ same ( "{:10s}" , [ Argument ( Argument {
807807 position : ArgumentNext ,
808808 format : FormatSpec {
809809 fill : None ,
@@ -815,7 +815,7 @@ mod tests {
815815 } ,
816816 method : None ,
817817 } ) ] ) ;
818- same ( "{:10$.10s}" , ~ [ Argument ( Argument {
818+ same ( "{:10$.10s}" , [ Argument ( Argument {
819819 position : ArgumentNext ,
820820 format : FormatSpec {
821821 fill : None ,
@@ -827,7 +827,7 @@ mod tests {
827827 } ,
828828 method : None ,
829829 } ) ] ) ;
830- same ( "{:.*s}" , ~ [ Argument ( Argument {
830+ same ( "{:.*s}" , [ Argument ( Argument {
831831 position : ArgumentNext ,
832832 format : FormatSpec {
833833 fill : None ,
@@ -839,7 +839,7 @@ mod tests {
839839 } ,
840840 method : None ,
841841 } ) ] ) ;
842- same ( "{:.10$s}" , ~ [ Argument ( Argument {
842+ same ( "{:.10$s}" , [ Argument ( Argument {
843843 position : ArgumentNext ,
844844 format : FormatSpec {
845845 fill : None ,
@@ -851,7 +851,7 @@ mod tests {
851851 } ,
852852 method : None ,
853853 } ) ] ) ;
854- same ( "{:a$.b$s}" , ~ [ Argument ( Argument {
854+ same ( "{:a$.b$s}" , [ Argument ( Argument {
855855 position : ArgumentNext ,
856856 format : FormatSpec {
857857 fill : None ,
@@ -866,7 +866,7 @@ mod tests {
866866 }
867867 #[ test]
868868 fn format_flags ( ) {
869- same ( "{:-}" , ~ [ Argument ( Argument {
869+ same ( "{:-}" , [ Argument ( Argument {
870870 position : ArgumentNext ,
871871 format : FormatSpec {
872872 fill : None ,
@@ -878,7 +878,7 @@ mod tests {
878878 } ,
879879 method : None ,
880880 } ) ] ) ;
881- same ( "{:+#}" , ~ [ Argument ( Argument {
881+ same ( "{:+#}" , [ Argument ( Argument {
882882 position : ArgumentNext ,
883883 format : FormatSpec {
884884 fill : None ,
@@ -893,7 +893,7 @@ mod tests {
893893 }
894894 #[ test]
895895 fn format_mixture ( ) {
896- same ( "abcd {3:a} efg" , ~ [ String ( "abcd " ) , Argument ( Argument {
896+ same ( "abcd {3:a} efg" , [ String ( "abcd " ) , Argument ( Argument {
897897 position : ArgumentIs ( 3 ) ,
898898 format : FormatSpec {
899899 fill : None ,
@@ -909,42 +909,42 @@ mod tests {
909909
910910 #[ test]
911911 fn select_simple ( ) {
912- same ( "{, select, other { haha } }" , ~ [ Argument ( Argument {
912+ same ( "{, select, other { haha } }" , [ Argument ( Argument {
913913 position : ArgumentNext ,
914914 format : fmtdflt ( ) ,
915- method : Some ( ~Select ( ~ [ ] , ~ [ String ( " haha " ) ] ) )
915+ method : Some ( ~Select ( vec ! [ ] , vec ! [ String ( " haha " ) ] ) )
916916 } ) ] ) ;
917- same ( "{1, select, other { haha } }" , ~ [ Argument ( Argument {
917+ same ( "{1, select, other { haha } }" , [ Argument ( Argument {
918918 position : ArgumentIs ( 1 ) ,
919919 format : fmtdflt ( ) ,
920- method : Some ( ~Select ( ~ [ ] , ~ [ String ( " haha " ) ] ) )
920+ method : Some ( ~Select ( vec ! [ ] , vec ! [ String ( " haha " ) ] ) )
921921 } ) ] ) ;
922- same ( "{1, select, other {#} }" , ~ [ Argument ( Argument {
922+ same ( "{1, select, other {#} }" , [ Argument ( Argument {
923923 position : ArgumentIs ( 1 ) ,
924924 format : fmtdflt ( ) ,
925- method : Some ( ~Select ( ~ [ ] , ~ [ CurrentArgument ] ) )
925+ method : Some ( ~Select ( vec ! [ ] , vec ! [ CurrentArgument ] ) )
926926 } ) ] ) ;
927- same ( "{1, select, other {{2, select, other {lol}}} }" , ~ [ Argument ( Argument {
927+ same ( "{1, select, other {{2, select, other {lol}}} }" , [ Argument ( Argument {
928928 position : ArgumentIs ( 1 ) ,
929929 format : fmtdflt ( ) ,
930- method : Some ( ~Select ( ~ [ ] , ~ [ Argument ( Argument {
930+ method : Some ( ~Select ( vec ! [ ] , vec ! [ Argument ( Argument {
931931 position: ArgumentIs ( 2 ) ,
932932 format: fmtdflt( ) ,
933- method : Some ( ~Select ( ~ [ ] , ~ [ String ( "lol" ) ] ) )
933+ method: Some ( ~Select ( vec! [ ] , vec! [ String ( "lol" ) ] ) )
934934 } ) ] ) ) // wat
935935 } ) ] ) ;
936936 }
937937
938938 #[ test]
939939 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 {
941941 position : ArgumentIs ( 1 ) ,
942942 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" ) ] ) )
948948 } ) ] ) ;
949949 }
950950
@@ -961,25 +961,25 @@ mod tests {
961961
962962 #[ test]
963963 fn plural_simple ( ) {
964- same ( "{, plural, other { haha } }" , ~ [ Argument ( Argument {
964+ same ( "{, plural, other { haha } }" , [ Argument ( Argument {
965965 position : ArgumentNext ,
966966 format : fmtdflt ( ) ,
967- method : Some ( ~Plural ( None , ~ [ ] , ~ [ String ( " haha " ) ] ) )
967+ method : Some ( ~Plural ( None , vec ! [ ] , vec ! [ String ( " haha " ) ] ) )
968968 } ) ] ) ;
969- same ( "{:, plural, other { haha } }" , ~ [ Argument ( Argument {
969+ same ( "{:, plural, other { haha } }" , [ Argument ( Argument {
970970 position : ArgumentNext ,
971971 format : fmtdflt ( ) ,
972- method : Some ( ~Plural ( None , ~ [ ] , ~ [ String ( " haha " ) ] ) )
972+ method : Some ( ~Plural ( None , vec ! [ ] , vec ! [ String ( " haha " ) ] ) )
973973 } ) ] ) ;
974974 same ( "{, plural, offset:1 =2{2} =3{3} many{yes} other{haha} }" ,
975- ~ [ Argument ( Argument {
975+ [ Argument ( Argument {
976976 position : ArgumentNext ,
977977 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" ) ] ) )
983983 } ) ] ) ;
984984 }
985985}
0 commit comments