@@ -76,8 +76,9 @@ pub enum CFloatType {
7676}
7777
7878impl CFloatType {
79- fn case ( self ) -> Case {
79+ const fn case ( self ) -> Case {
8080 use CFloatType :: * ;
81+
8182 match self {
8283 ExponentLower | PointDecimalLower | GeneralLower => Case :: Lower ,
8384 ExponentUpper | PointDecimalUpper | GeneralUpper => Case :: Upper ,
@@ -100,7 +101,7 @@ pub enum CFormatType {
100101}
101102
102103impl CFormatType {
103- pub fn to_char ( self ) -> char {
104+ pub const fn to_char ( self ) -> char {
104105 match self {
105106 CFormatType :: Number ( x) => x as u8 as char ,
106107 CFormatType :: Float ( x) => x as u8 as char ,
@@ -136,9 +137,9 @@ bitflags! {
136137impl CConversionFlags {
137138 #[ inline]
138139 pub fn sign_string ( & self ) -> & ' static str {
139- if self . contains ( CConversionFlags :: SIGN_CHAR ) {
140+ if self . contains ( Self :: SIGN_CHAR ) {
140141 "+"
141- } else if self . contains ( CConversionFlags :: BLANK_SIGN ) {
142+ } else if self . contains ( Self :: BLANK_SIGN ) {
142143 " "
143144 } else {
144145 ""
@@ -171,12 +172,15 @@ pub trait FormatChar: Copy + Into<CodePoint> + From<u8> {
171172
172173impl FormatBuf for String {
173174 type Char = char ;
175+
174176 fn chars ( & self ) -> impl Iterator < Item = Self :: Char > {
175177 ( * * self ) . chars ( )
176178 }
179+
177180 fn len ( & self ) -> usize {
178181 self . len ( )
179182 }
183+
180184 fn concat ( mut self , other : Self ) -> Self {
181185 self . extend ( [ other] ) ;
182186 self
@@ -187,19 +191,23 @@ impl FormatChar for char {
187191 fn to_char_lossy ( self ) -> char {
188192 self
189193 }
194+
190195 fn eq_char ( self , c : char ) -> bool {
191196 self == c
192197 }
193198}
194199
195200impl FormatBuf for Wtf8Buf {
196201 type Char = CodePoint ;
202+
197203 fn chars ( & self ) -> impl Iterator < Item = Self :: Char > {
198204 self . code_points ( )
199205 }
206+
200207 fn len ( & self ) -> usize {
201208 ( * * self ) . len ( )
202209 }
210+
203211 fn concat ( mut self , other : Self ) -> Self {
204212 self . extend ( [ other] ) ;
205213 self
@@ -210,19 +218,23 @@ impl FormatChar for CodePoint {
210218 fn to_char_lossy ( self ) -> char {
211219 self . to_char_lossy ( )
212220 }
221+
213222 fn eq_char ( self , c : char ) -> bool {
214223 self == c
215224 }
216225}
217226
218227impl FormatBuf for Vec < u8 > {
219228 type Char = u8 ;
229+
220230 fn chars ( & self ) -> impl Iterator < Item = Self :: Char > {
221231 self . iter ( ) . copied ( )
222232 }
233+
223234 fn len ( & self ) -> usize {
224235 self . len ( )
225236 }
237+
226238 fn concat ( mut self , other : Self ) -> Self {
227239 self . extend ( other) ;
228240 self
@@ -233,6 +245,7 @@ impl FormatChar for u8 {
233245 fn to_char_lossy ( self ) -> char {
234246 self . into ( )
235247 }
248+
236249 fn eq_char ( self , c : char ) -> bool {
237250 char:: from ( self ) == c
238251 }
@@ -393,6 +406,7 @@ impl CFormatSpec {
393406 Some ( & ( CFormatQuantity :: Amount ( 1 ) . into ( ) ) ) ,
394407 )
395408 }
409+
396410 pub fn format_bytes ( & self , bytes : & [ u8 ] ) -> Vec < u8 > {
397411 let bytes = if let Some ( CFormatPrecision :: Quantity ( CFormatQuantity :: Amount ( precision) ) ) =
398412 self . precision
@@ -706,12 +720,12 @@ pub enum CFormatPart<T> {
706720
707721impl < T > CFormatPart < T > {
708722 #[ inline]
709- pub fn is_specifier ( & self ) -> bool {
723+ pub const fn is_specifier ( & self ) -> bool {
710724 matches ! ( self , CFormatPart :: Spec { .. } )
711725 }
712726
713727 #[ inline]
714- pub fn has_key ( & self ) -> bool {
728+ pub const fn has_key ( & self ) -> bool {
715729 match self {
716730 CFormatPart :: Spec ( s) => s. mapping_key . is_some ( ) ,
717731 _ => false ,
@@ -803,6 +817,7 @@ impl<S> CFormatStrOrBytes<S> {
803817impl < S > IntoIterator for CFormatStrOrBytes < S > {
804818 type Item = ( usize , CFormatPart < S > ) ;
805819 type IntoIter = std:: vec:: IntoIter < Self :: Item > ;
820+
806821 fn into_iter ( self ) -> Self :: IntoIter {
807822 self . parts . into_iter ( )
808823 }
0 commit comments