diff options
| author | Tommy Ip <hkmp7tommy@gmail.com> | 2017-11-09 17:16:25 +0000 |
|---|---|---|
| committer | Tommy Ip <hkmp7tommy@gmail.com> | 2017-11-09 20:57:58 +0000 |
| commit | b577b9aef357398252bfff630d69efabfceb50e8 (patch) | |
| tree | 36cc55a64bb2f6a712260956bb61bae98b750d37 /src/libfmt_macros | |
| parent | 13a416298c1670f0304eeb64f46a410cd1bb5e8e (diff) | |
| download | rust-b577b9aef357398252bfff630d69efabfceb50e8.tar.gz rust-b577b9aef357398252bfff630d69efabfceb50e8.zip | |
Retain information on whether a format argument has explicit position
Diffstat (limited to 'src/libfmt_macros')
| -rw-r--r-- | src/libfmt_macros/lib.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 24430b2e377..44cdb5e8a36 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -73,7 +73,9 @@ pub struct FormatSpec<'a> { /// Enum describing where an argument for a format can be located. #[derive(Copy, Clone, PartialEq)] pub enum Position<'a> { - /// The argument is located at a specific index. + /// The arugment is implied to be located at an index + ArgumentImplicitlyIs(usize), + /// The argument is located at a specific index given in the format ArgumentIs(usize), /// The argument has a name. ArgumentNamed(&'a str), @@ -275,7 +277,7 @@ impl<'a> Parser<'a> { None => { let i = self.curarg; self.curarg += 1; - ArgumentIs(i) + ArgumentImplicitlyIs(i) } }; @@ -517,7 +519,7 @@ mod tests { fn format_nothing() { same("{}", &[NextArgument(Argument { - position: ArgumentIs(0), + position: ArgumentImplicitlyIs(0), format: fmtdflt(), })]); } @@ -595,7 +597,7 @@ mod tests { fn format_counts() { same("{:10s}", &[NextArgument(Argument { - position: ArgumentIs(0), + position: ArgumentImplicitlyIs(0), format: FormatSpec { fill: None, align: AlignUnknown, @@ -607,7 +609,7 @@ mod tests { })]); same("{:10$.10s}", &[NextArgument(Argument { - position: ArgumentIs(0), + position: ArgumentImplicitlyIs(0), format: FormatSpec { fill: None, align: AlignUnknown, @@ -619,7 +621,7 @@ mod tests { })]); same("{:.*s}", &[NextArgument(Argument { - position: ArgumentIs(1), + position: ArgumentImplicitlyIs(1), format: FormatSpec { fill: None, align: AlignUnknown, @@ -631,7 +633,7 @@ mod tests { })]); same("{:.10$s}", &[NextArgument(Argument { - position: ArgumentIs(0), + position: ArgumentImplicitlyIs(0), format: FormatSpec { fill: None, align: AlignUnknown, @@ -643,7 +645,7 @@ mod tests { })]); same("{:a$.b$s}", &[NextArgument(Argument { - position: ArgumentIs(0), + position: ArgumentImplicitlyIs(0), format: FormatSpec { fill: None, align: AlignUnknown, @@ -658,7 +660,7 @@ mod tests { fn format_flags() { same("{:-}", &[NextArgument(Argument { - position: ArgumentIs(0), + position: ArgumentImplicitlyIs(0), format: FormatSpec { fill: None, align: AlignUnknown, @@ -670,7 +672,7 @@ mod tests { })]); same("{:+#}", &[NextArgument(Argument { - position: ArgumentIs(0), + position: ArgumentImplicitlyIs(0), format: FormatSpec { fill: None, align: AlignUnknown, |
