23
23
24
24
use std:: char;
25
25
use std:: str;
26
+ use std:: string;
26
27
27
28
/// A piece is a portion of the format string which represents the next part
28
29
/// to emit. These are emitted as a stream by the `Parser` class.
@@ -32,7 +33,7 @@ pub enum Piece<'a> {
32
33
String ( & ' a str ) ,
33
34
/// This describes that formatting should process the next argument (as
34
35
/// specified inside) for emission.
35
- Argument ( Argument < ' a > ) ,
36
+ NextArgument ( Argument < ' a > ) ,
36
37
}
37
38
38
39
/// Representation of an argument specification.
@@ -129,7 +130,7 @@ pub struct Parser<'a> {
129
130
input : & ' a str ,
130
131
cur : str:: CharOffsets < ' a > ,
131
132
/// Error messages accumulated during parsing
132
- pub errors : Vec < String > ,
133
+ pub errors : Vec < string :: String > ,
133
134
}
134
135
135
136
impl < ' a > Iterator < Piece < ' a > > for Parser < ' a > {
@@ -140,7 +141,7 @@ impl<'a> Iterator<Piece<'a>> for Parser<'a> {
140
141
if self . consume ( '{' ) {
141
142
Some ( String ( self . string ( pos + 1 ) ) )
142
143
} else {
143
- let ret = Some ( Argument ( self . argument ( ) ) ) ;
144
+ let ret = Some ( NextArgument ( self . argument ( ) ) ) ;
144
145
self . must_consume ( '}' ) ;
145
146
ret
146
147
}
@@ -469,28 +470,28 @@ mod tests {
469
470
470
471
#[ test]
471
472
fn format_nothing ( ) {
472
- same ( "{}" , [ Argument ( Argument {
473
+ same ( "{}" , [ NextArgument ( Argument {
473
474
position : ArgumentNext ,
474
475
format : fmtdflt ( ) ,
475
476
} ) ] ) ;
476
477
}
477
478
#[ test]
478
479
fn format_position ( ) {
479
- same ( "{3}" , [ Argument ( Argument {
480
+ same ( "{3}" , [ NextArgument ( Argument {
480
481
position : ArgumentIs ( 3 ) ,
481
482
format : fmtdflt ( ) ,
482
483
} ) ] ) ;
483
484
}
484
485
#[ test]
485
486
fn format_position_nothing_else ( ) {
486
- same ( "{3:}" , [ Argument ( Argument {
487
+ same ( "{3:}" , [ NextArgument ( Argument {
487
488
position : ArgumentIs ( 3 ) ,
488
489
format : fmtdflt ( ) ,
489
490
} ) ] ) ;
490
491
}
491
492
#[ test]
492
493
fn format_type ( ) {
493
- same ( "{3:a}" , [ Argument ( Argument {
494
+ same ( "{3:a}" , [ NextArgument ( Argument {
494
495
position : ArgumentIs ( 3 ) ,
495
496
format : FormatSpec {
496
497
fill : None ,
@@ -504,7 +505,7 @@ mod tests {
504
505
}
505
506
#[ test]
506
507
fn format_align_fill ( ) {
507
- same ( "{3:>}" , [ Argument ( Argument {
508
+ same ( "{3:>}" , [ NextArgument ( Argument {
508
509
position : ArgumentIs ( 3 ) ,
509
510
format : FormatSpec {
510
511
fill : None ,
@@ -515,7 +516,7 @@ mod tests {
515
516
ty : "" ,
516
517
} ,
517
518
} ) ] ) ;
518
- same ( "{3:0<}" , [ Argument ( Argument {
519
+ same ( "{3:0<}" , [ NextArgument ( Argument {
519
520
position : ArgumentIs ( 3 ) ,
520
521
format : FormatSpec {
521
522
fill : Some ( '0' ) ,
@@ -526,7 +527,7 @@ mod tests {
526
527
ty : "" ,
527
528
} ,
528
529
} ) ] ) ;
529
- same ( "{3:*<abcd}" , [ Argument ( Argument {
530
+ same ( "{3:*<abcd}" , [ NextArgument ( Argument {
530
531
position : ArgumentIs ( 3 ) ,
531
532
format : FormatSpec {
532
533
fill : Some ( '*' ) ,
@@ -540,7 +541,7 @@ mod tests {
540
541
}
541
542
#[ test]
542
543
fn format_counts ( ) {
543
- same ( "{:10s}" , [ Argument ( Argument {
544
+ same ( "{:10s}" , [ NextArgument ( Argument {
544
545
position : ArgumentNext ,
545
546
format : FormatSpec {
546
547
fill : None ,
@@ -551,7 +552,7 @@ mod tests {
551
552
ty : "s" ,
552
553
} ,
553
554
} ) ] ) ;
554
- same ( "{:10$.10s}" , [ Argument ( Argument {
555
+ same ( "{:10$.10s}" , [ NextArgument ( Argument {
555
556
position : ArgumentNext ,
556
557
format : FormatSpec {
557
558
fill : None ,
@@ -562,7 +563,7 @@ mod tests {
562
563
ty : "s" ,
563
564
} ,
564
565
} ) ] ) ;
565
- same ( "{:.*s}" , [ Argument ( Argument {
566
+ same ( "{:.*s}" , [ NextArgument ( Argument {
566
567
position : ArgumentNext ,
567
568
format : FormatSpec {
568
569
fill : None ,
@@ -573,7 +574,7 @@ mod tests {
573
574
ty : "s" ,
574
575
} ,
575
576
} ) ] ) ;
576
- same ( "{:.10$s}" , [ Argument ( Argument {
577
+ same ( "{:.10$s}" , [ NextArgument ( Argument {
577
578
position : ArgumentNext ,
578
579
format : FormatSpec {
579
580
fill : None ,
@@ -584,7 +585,7 @@ mod tests {
584
585
ty : "s" ,
585
586
} ,
586
587
} ) ] ) ;
587
- same ( "{:a$.b$s}" , [ Argument ( Argument {
588
+ same ( "{:a$.b$s}" , [ NextArgument ( Argument {
588
589
position : ArgumentNext ,
589
590
format : FormatSpec {
590
591
fill : None ,
@@ -598,7 +599,7 @@ mod tests {
598
599
}
599
600
#[ test]
600
601
fn format_flags ( ) {
601
- same ( "{:-}" , [ Argument ( Argument {
602
+ same ( "{:-}" , [ NextArgument ( Argument {
602
603
position : ArgumentNext ,
603
604
format : FormatSpec {
604
605
fill : None ,
@@ -609,7 +610,7 @@ mod tests {
609
610
ty : "" ,
610
611
} ,
611
612
} ) ] ) ;
612
- same ( "{:+#}" , [ Argument ( Argument {
613
+ same ( "{:+#}" , [ NextArgument ( Argument {
613
614
position : ArgumentNext ,
614
615
format : FormatSpec {
615
616
fill : None ,
@@ -623,7 +624,7 @@ mod tests {
623
624
}
624
625
#[ test]
625
626
fn format_mixture ( ) {
626
- same ( "abcd {3:a} efg" , [ String ( "abcd " ) , Argument ( Argument {
627
+ same ( "abcd {3:a} efg" , [ String ( "abcd " ) , NextArgument ( Argument {
627
628
position : ArgumentIs ( 3 ) ,
628
629
format : FormatSpec {
629
630
fill : None ,
0 commit comments