@@ -38,23 +38,23 @@ impl FormatParse for FormatConversion {
3838}
3939
4040impl FormatConversion {
41- pub fn from_char ( c : CodePoint ) -> Option < FormatConversion > {
41+ pub fn from_char ( c : CodePoint ) -> Option < Self > {
4242 match c. to_char_lossy ( ) {
43- 's' => Some ( FormatConversion :: Str ) ,
44- 'r' => Some ( FormatConversion :: Repr ) ,
45- 'a' => Some ( FormatConversion :: Ascii ) ,
46- 'b' => Some ( FormatConversion :: Bytes ) ,
43+ 's' => Some ( Self :: Str ) ,
44+ 'r' => Some ( Self :: Repr ) ,
45+ 'a' => Some ( Self :: Ascii ) ,
46+ 'b' => Some ( Self :: Bytes ) ,
4747 _ => None ,
4848 }
4949 }
5050
51- fn from_string ( text : & Wtf8 ) -> Option < FormatConversion > {
51+ fn from_string ( text : & Wtf8 ) -> Option < Self > {
5252 let mut chars = text. code_points ( ) ;
5353 if chars. next ( ) ? != '!' {
5454 return None ;
5555 }
5656
57- FormatConversion :: from_char ( chars. next ( ) ?)
57+ Self :: from_char ( chars. next ( ) ?)
5858 }
5959}
6060
@@ -67,12 +67,12 @@ pub enum FormatAlign {
6767}
6868
6969impl FormatAlign {
70- fn from_char ( c : CodePoint ) -> Option < FormatAlign > {
70+ fn from_char ( c : CodePoint ) -> Option < Self > {
7171 match c. to_char_lossy ( ) {
72- '<' => Some ( FormatAlign :: Left ) ,
73- '>' => Some ( FormatAlign :: Right ) ,
74- '=' => Some ( FormatAlign :: AfterSign ) ,
75- '^' => Some ( FormatAlign :: Center ) ,
72+ '<' => Some ( Self :: Left ) ,
73+ '>' => Some ( Self :: Right ) ,
74+ '=' => Some ( Self :: AfterSign ) ,
75+ '^' => Some ( Self :: Center ) ,
7676 _ => None ,
7777 }
7878 }
@@ -141,7 +141,7 @@ pub enum FormatType {
141141}
142142
143143impl From < & FormatType > for char {
144- fn from ( from : & FormatType ) -> char {
144+ fn from ( from : & FormatType ) -> Self {
145145 match from {
146146 FormatType :: String => 's' ,
147147 FormatType :: Binary => 'b' ,
@@ -299,7 +299,7 @@ impl FormatSpec {
299299 align = align. or ( Some ( FormatAlign :: AfterSign ) ) ;
300300 }
301301
302- Ok ( FormatSpec {
302+ Ok ( Self {
303303 conversion,
304304 fill,
305305 align,
@@ -327,7 +327,7 @@ impl FormatSpec {
327327 let magnitude_int_str = parts. next ( ) . unwrap ( ) . to_string ( ) ;
328328 let dec_digit_cnt = magnitude_str. len ( ) as i32 - magnitude_int_str. len ( ) as i32 ;
329329 let int_digit_cnt = disp_digit_cnt - dec_digit_cnt;
330- let mut result = FormatSpec :: separate_integer ( magnitude_int_str, inter, sep, int_digit_cnt) ;
330+ let mut result = Self :: separate_integer ( magnitude_int_str, inter, sep, int_digit_cnt) ;
331331 if let Some ( part) = parts. next ( ) {
332332 result. push_str ( & format ! ( ".{part}" ) )
333333 }
@@ -350,11 +350,11 @@ impl FormatSpec {
350350 // separate with 0 padding
351351 let padding = "0" . repeat ( diff as usize ) ;
352352 let padded_num = format ! ( "{padding}{magnitude_str}" ) ;
353- FormatSpec :: insert_separator ( padded_num, inter, sep, sep_cnt)
353+ Self :: insert_separator ( padded_num, inter, sep, sep_cnt)
354354 } else {
355355 // separate without padding
356356 let sep_cnt = ( magnitude_len - 1 ) / inter;
357- FormatSpec :: insert_separator ( magnitude_str, inter, sep, sep_cnt)
357+ Self :: insert_separator ( magnitude_str, inter, sep, sep_cnt)
358358 }
359359 }
360360
@@ -412,12 +412,7 @@ impl FormatSpec {
412412 let magnitude_len = magnitude_str. len ( ) ;
413413 let width = self . width . unwrap_or ( magnitude_len) as i32 - prefix. len ( ) as i32 ;
414414 let disp_digit_cnt = cmp:: max ( width, magnitude_len as i32 ) ;
415- FormatSpec :: add_magnitude_separators_for_char (
416- magnitude_str,
417- inter,
418- sep,
419- disp_digit_cnt,
420- )
415+ Self :: add_magnitude_separators_for_char ( magnitude_str, inter, sep, disp_digit_cnt)
421416 }
422417 None => magnitude_str,
423418 }
@@ -640,27 +635,26 @@ impl FormatSpec {
640635 "{}{}{}" ,
641636 sign_str,
642637 magnitude_str,
643- FormatSpec :: compute_fill_string( fill_char, fill_chars_needed)
638+ Self :: compute_fill_string( fill_char, fill_chars_needed)
644639 ) ,
645640 FormatAlign :: Right => format ! (
646641 "{}{}{}" ,
647- FormatSpec :: compute_fill_string( fill_char, fill_chars_needed) ,
642+ Self :: compute_fill_string( fill_char, fill_chars_needed) ,
648643 sign_str,
649644 magnitude_str
650645 ) ,
651646 FormatAlign :: AfterSign => format ! (
652647 "{}{}{}" ,
653648 sign_str,
654- FormatSpec :: compute_fill_string( fill_char, fill_chars_needed) ,
649+ Self :: compute_fill_string( fill_char, fill_chars_needed) ,
655650 magnitude_str
656651 ) ,
657652 FormatAlign :: Center => {
658653 let left_fill_chars_needed = fill_chars_needed / 2 ;
659654 let right_fill_chars_needed = fill_chars_needed - left_fill_chars_needed;
660- let left_fill_string =
661- FormatSpec :: compute_fill_string ( fill_char, left_fill_chars_needed) ;
655+ let left_fill_string = Self :: compute_fill_string ( fill_char, left_fill_chars_needed) ;
662656 let right_fill_string =
663- FormatSpec :: compute_fill_string ( fill_char, right_fill_chars_needed) ;
657+ Self :: compute_fill_string ( fill_char, right_fill_chars_needed) ;
664658 format ! ( "{left_fill_string}{sign_str}{magnitude_str}{right_fill_string}" )
665659 }
666660 } )
@@ -725,7 +719,7 @@ pub enum FormatParseError {
725719impl FromStr for FormatSpec {
726720 type Err = FormatSpecError ;
727721 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
728- FormatSpec :: parse ( s)
722+ Self :: parse ( s)
729723 }
730724}
731725
@@ -739,7 +733,7 @@ pub enum FieldNamePart {
739733impl FieldNamePart {
740734 fn parse_part (
741735 chars : & mut impl PeekingNext < Item = CodePoint > ,
742- ) -> Result < Option < FieldNamePart > , FormatParseError > {
736+ ) -> Result < Option < Self > , FormatParseError > {
743737 chars
744738 . next ( )
745739 . map ( |ch| match ch. to_char_lossy ( ) {
@@ -751,7 +745,7 @@ impl FieldNamePart {
751745 if attribute. is_empty ( ) {
752746 Err ( FormatParseError :: EmptyAttribute )
753747 } else {
754- Ok ( FieldNamePart :: Attribute ( attribute) )
748+ Ok ( Self :: Attribute ( attribute) )
755749 }
756750 }
757751 '[' => {
@@ -761,9 +755,9 @@ impl FieldNamePart {
761755 return if index. is_empty ( ) {
762756 Err ( FormatParseError :: EmptyAttribute )
763757 } else if let Some ( index) = parse_usize ( & index) {
764- Ok ( FieldNamePart :: Index ( index) )
758+ Ok ( Self :: Index ( index) )
765759 } else {
766- Ok ( FieldNamePart :: StringIndex ( index) )
760+ Ok ( Self :: StringIndex ( index) )
767761 } ;
768762 }
769763 index. push ( ch) ;
@@ -794,7 +788,7 @@ fn parse_usize(s: &Wtf8) -> Option<usize> {
794788}
795789
796790impl FieldName {
797- pub fn parse ( text : & Wtf8 ) -> Result < FieldName , FormatParseError > {
791+ pub fn parse ( text : & Wtf8 ) -> Result < Self , FormatParseError > {
798792 let mut chars = text. code_points ( ) . peekable ( ) ;
799793 let first: Wtf8Buf = chars
800794 . peeking_take_while ( |ch| * ch != '.' && * ch != '[' )
@@ -813,7 +807,7 @@ impl FieldName {
813807 parts. push ( part)
814808 }
815809
816- Ok ( FieldName { field_type, parts } )
810+ Ok ( Self { field_type, parts } )
817811 }
818812}
819813
@@ -854,7 +848,7 @@ impl FormatString {
854848 let mut cur_text = text;
855849 let mut result_string = Wtf8Buf :: new ( ) ;
856850 while !cur_text. is_empty ( ) {
857- match FormatString :: parse_literal_single ( cur_text) {
851+ match Self :: parse_literal_single ( cur_text) {
858852 Ok ( ( next_char, remaining) ) => {
859853 result_string. push ( next_char) ;
860854 cur_text = remaining;
@@ -968,7 +962,7 @@ impl FormatString {
968962 }
969963 if let Some ( pos) = end_bracket_pos {
970964 let right = & text[ pos..] ;
971- let format_part = FormatString :: parse_part_in_brackets ( & left) ?;
965+ let format_part = Self :: parse_part_in_brackets ( & left) ?;
972966 Ok ( ( format_part, & right[ 1 ..] ) )
973967 } else {
974968 Err ( FormatParseError :: UnmatchedBracket )
@@ -990,14 +984,14 @@ impl<'a> FromTemplate<'a> for FormatString {
990984 while !cur_text. is_empty ( ) {
991985 // Try to parse both literals and bracketed format parts until we
992986 // run out of text
993- cur_text = FormatString :: parse_literal ( cur_text)
994- . or_else ( |_| FormatString :: parse_spec ( cur_text) )
987+ cur_text = Self :: parse_literal ( cur_text)
988+ . or_else ( |_| Self :: parse_spec ( cur_text) )
995989 . map ( |( part, new_text) | {
996990 parts. push ( part) ;
997991 new_text
998992 } ) ?;
999993 }
1000- Ok ( FormatString {
994+ Ok ( Self {
1001995 format_parts : parts,
1002996 } )
1003997 }
0 commit comments