@@ -56,30 +56,12 @@ pub struct Argument<'a> {
5656
5757impl < ' a > Argument < ' a > {
5858 pub fn is_identifier ( & self ) -> bool {
59- matches ! ( self . position, Position :: ArgumentNamed ( _) )
60- && matches ! (
61- self . format,
62- FormatSpec {
63- fill: None ,
64- fill_span: None ,
65- align: AlignUnknown ,
66- sign: None ,
67- alternate: false ,
68- zero_pad: false ,
69- debug_hex: None ,
70- precision: CountImplied ,
71- precision_span: None ,
72- width: CountImplied ,
73- width_span: None ,
74- ty: "" ,
75- ty_span: None ,
76- } ,
77- )
59+ matches ! ( self . position, Position :: ArgumentNamed ( _) ) && self . format == FormatSpec :: default ( )
7860 }
7961}
8062
8163/// Specification for the formatting of an argument in the format string.
82- #[ derive( Clone , Debug , PartialEq ) ]
64+ #[ derive( Clone , Debug , PartialEq , Default ) ]
8365pub struct FormatSpec < ' a > {
8466 /// Optionally specified character to fill alignment with.
8567 pub fill : Option < char > ,
@@ -132,7 +114,7 @@ impl Position<'_> {
132114}
133115
134116/// Enum of alignments which are supported.
135- #[ derive( Copy , Clone , Debug , PartialEq ) ]
117+ #[ derive( Copy , Clone , Debug , PartialEq , Default ) ]
136118pub enum Alignment {
137119 /// The value will be aligned to the left.
138120 AlignLeft ,
@@ -141,6 +123,7 @@ pub enum Alignment {
141123 /// The value will be aligned in the center.
142124 AlignCenter ,
143125 /// The value will take on a default alignment.
126+ #[ default]
144127 AlignUnknown ,
145128}
146129
@@ -164,7 +147,7 @@ pub enum DebugHex {
164147
165148/// A count is used for the precision and width parameters of an integer, and
166149/// can reference either an argument or a literal integer.
167- #[ derive( Clone , Debug , PartialEq ) ]
150+ #[ derive( Clone , Debug , PartialEq , Default ) ]
168151pub enum Count < ' a > {
169152 /// The count is specified explicitly.
170153 CountIs ( u16 ) ,
@@ -175,6 +158,7 @@ pub enum Count<'a> {
175158 /// The count is specified by a star (like in `{:.*}`) that refers to the argument at the given index.
176159 CountIsStar ( usize ) ,
177160 /// The count is implied and cannot be explicitly specified.
161+ #[ default]
178162 CountImplied ,
179163}
180164
@@ -596,21 +580,8 @@ impl<'a> Parser<'a> {
596580 /// Parses a format specifier at the current position, returning all of the
597581 /// relevant information in the `FormatSpec` struct.
598582 fn format ( & mut self ) -> FormatSpec < ' a > {
599- let mut spec = FormatSpec {
600- fill : None ,
601- fill_span : None ,
602- align : AlignUnknown ,
603- sign : None ,
604- alternate : false ,
605- zero_pad : false ,
606- debug_hex : None ,
607- precision : CountImplied ,
608- precision_span : None ,
609- width : CountImplied ,
610- width_span : None ,
611- ty : & self . input [ ..0 ] ,
612- ty_span : None ,
613- } ;
583+ let mut spec = FormatSpec :: default ( ) ;
584+
614585 if !self . consume ( ':' ) {
615586 return spec;
616587 }
@@ -727,21 +698,8 @@ impl<'a> Parser<'a> {
727698 /// Parses an inline assembly template modifier at the current position, returning the modifier
728699 /// in the `ty` field of the `FormatSpec` struct.
729700 fn inline_asm ( & mut self ) -> FormatSpec < ' a > {
730- let mut spec = FormatSpec {
731- fill : None ,
732- fill_span : None ,
733- align : AlignUnknown ,
734- sign : None ,
735- alternate : false ,
736- zero_pad : false ,
737- debug_hex : None ,
738- precision : CountImplied ,
739- precision_span : None ,
740- width : CountImplied ,
741- width_span : None ,
742- ty : & self . input [ ..0 ] ,
743- ty_span : None ,
744- } ;
701+ let mut spec = FormatSpec :: default ( ) ;
702+
745703 if !self . consume ( ':' ) {
746704 return spec;
747705 }
0 commit comments