@@ -12,43 +12,43 @@ trait FormatParse {
1212}
1313
1414#[ derive( Debug , Copy , Clone , PartialEq ) ]
15- pub enum FormatPreconversor {
15+ pub enum FormatConversion {
1616 Str ,
1717 Repr ,
1818 Ascii ,
1919 Bytes ,
2020}
2121
22- impl FormatParse for FormatPreconversor {
22+ impl FormatParse for FormatConversion {
2323 fn parse ( text : & str ) -> ( Option < Self > , & str ) {
24- let Some ( preconversor ) = Self :: from_string ( text) else {
24+ let Some ( conversion ) = Self :: from_string ( text) else {
2525 return ( None , text) ;
2626 } ;
2727 let mut chars = text. chars ( ) ;
2828 chars. next ( ) ; // Consume the bang
2929 chars. next ( ) ; // Consume one r,s,a char
30- ( Some ( preconversor ) , chars. as_str ( ) )
30+ ( Some ( conversion ) , chars. as_str ( ) )
3131 }
3232}
3333
34- impl FormatPreconversor {
35- pub fn from_char ( c : char ) -> Option < FormatPreconversor > {
34+ impl FormatConversion {
35+ pub fn from_char ( c : char ) -> Option < FormatConversion > {
3636 match c {
37- 's' => Some ( FormatPreconversor :: Str ) ,
38- 'r' => Some ( FormatPreconversor :: Repr ) ,
39- 'a' => Some ( FormatPreconversor :: Ascii ) ,
40- 'b' => Some ( FormatPreconversor :: Bytes ) ,
37+ 's' => Some ( FormatConversion :: Str ) ,
38+ 'r' => Some ( FormatConversion :: Repr ) ,
39+ 'a' => Some ( FormatConversion :: Ascii ) ,
40+ 'b' => Some ( FormatConversion :: Bytes ) ,
4141 _ => None ,
4242 }
4343 }
4444
45- fn from_string ( text : & str ) -> Option < FormatPreconversor > {
45+ fn from_string ( text : & str ) -> Option < FormatConversion > {
4646 let mut chars = text. chars ( ) ;
4747 if chars. next ( ) != Some ( '!' ) {
4848 return None ;
4949 }
5050
51- FormatPreconversor :: from_char ( chars. next ( ) ?)
51+ FormatConversion :: from_char ( chars. next ( ) ?)
5252 }
5353}
5454
@@ -182,7 +182,7 @@ impl FormatParse for FormatType {
182182
183183#[ derive( Debug , PartialEq ) ]
184184pub struct FormatSpec {
185- preconversor : Option < FormatPreconversor > ,
185+ conversion : Option < FormatConversion > ,
186186 fill : Option < char > ,
187187 align : Option < FormatAlign > ,
188188 sign : Option < FormatSign > ,
@@ -270,7 +270,7 @@ fn parse_precision(text: &str) -> Result<(Option<usize>, &str), FormatSpecError>
270270impl FormatSpec {
271271 pub fn parse ( text : & str ) -> Result < Self , FormatSpecError > {
272272 // get_integer in CPython
273- let ( preconversor , text) = FormatPreconversor :: parse ( text) ;
273+ let ( conversion , text) = FormatConversion :: parse ( text) ;
274274 let ( mut fill, mut align, text) = parse_fill_and_align ( text) ;
275275 let ( sign, text) = FormatSign :: parse ( text) ;
276276 let ( alternate_form, text) = parse_alternate_form ( text) ;
@@ -289,7 +289,7 @@ impl FormatSpec {
289289 }
290290
291291 Ok ( FormatSpec {
292- preconversor ,
292+ conversion ,
293293 fill,
294294 align,
295295 sign,
@@ -517,7 +517,7 @@ impl FormatSpec {
517517 } else {
518518 ""
519519 } ;
520- let raw_magnitude_str: Result < String , FormatSpecError > = match self . format_type {
520+ let raw_magnitude_str = match self . format_type {
521521 Some ( FormatType :: Binary ) => self . format_int_radix ( magnitude, 2 ) ,
522522 Some ( FormatType :: Decimal ) => self . format_int_radix ( magnitude, 10 ) ,
523523 Some ( FormatType :: Octal ) => self . format_int_radix ( magnitude, 8 ) ,
@@ -548,7 +548,7 @@ impl FormatSpec {
548548 _ => Err ( FormatSpecError :: UnableToConvert ) ,
549549 } ,
550550 None => self . format_int_radix ( magnitude, 10 ) ,
551- } ;
551+ } ? ;
552552 let format_sign = self . sign . unwrap_or ( FormatSign :: Minus ) ;
553553 let sign_str = match num. sign ( ) {
554554 Sign :: Minus => "-" ,
@@ -559,7 +559,7 @@ impl FormatSpec {
559559 } ,
560560 } ;
561561 let sign_prefix = format ! ( "{sign_str}{prefix}" ) ;
562- let magnitude_str = self . add_magnitude_separators ( raw_magnitude_str? , & sign_prefix) ;
562+ let magnitude_str = self . add_magnitude_separators ( raw_magnitude_str, & sign_prefix) ;
563563 self . format_sign_and_align (
564564 & BorrowedStr :: from_bytes ( magnitude_str. as_bytes ( ) ) ,
565565 & sign_prefix,
@@ -752,7 +752,7 @@ impl FieldName {
752752pub enum FormatPart {
753753 Field {
754754 field_name : String ,
755- preconversion_spec : Option < char > ,
755+ conversion_spec : Option < char > ,
756756 format_spec : String ,
757757 } ,
758758 Literal ( String ) ,
@@ -813,12 +813,12 @@ impl FormatString {
813813 String :: new ( )
814814 } ;
815815
816- // On parts[0] can still be the preconversor (!r, !s, !a)
816+ // On parts[0] can still be the conversion (!r, !s, !a)
817817 let parts: Vec < & str > = arg_part. splitn ( 2 , '!' ) . collect ( ) ;
818- // before the bang is a keyword or arg index, after the comma is maybe a conversor spec.
818+ // before the bang is a keyword or arg index, after the comma is maybe a conversion spec.
819819 let arg_part = parts[ 0 ] ;
820820
821- let preconversion_spec = parts
821+ let conversion_spec = parts
822822 . get ( 1 )
823823 . map ( |conversion| {
824824 // conversions are only every one character
@@ -831,7 +831,7 @@ impl FormatString {
831831
832832 Ok ( FormatPart :: Field {
833833 field_name : arg_part. to_owned ( ) ,
834- preconversion_spec ,
834+ conversion_spec ,
835835 format_spec,
836836 } )
837837 }
@@ -936,7 +936,7 @@ mod tests {
936936 #[ test]
937937 fn test_width_only ( ) {
938938 let expected = Ok ( FormatSpec {
939- preconversor : None ,
939+ conversion : None ,
940940 fill : None ,
941941 align : None ,
942942 sign : None ,
@@ -952,7 +952,7 @@ mod tests {
952952 #[ test]
953953 fn test_fill_and_width ( ) {
954954 let expected = Ok ( FormatSpec {
955- preconversor : None ,
955+ conversion : None ,
956956 fill : Some ( '<' ) ,
957957 align : Some ( FormatAlign :: Right ) ,
958958 sign : None ,
@@ -968,7 +968,7 @@ mod tests {
968968 #[ test]
969969 fn test_all ( ) {
970970 let expected = Ok ( FormatSpec {
971- preconversor : None ,
971+ conversion : None ,
972972 fill : Some ( '<' ) ,
973973 align : Some ( FormatAlign :: Right ) ,
974974 sign : Some ( FormatSign :: Minus ) ,
@@ -1034,13 +1034,13 @@ mod tests {
10341034 FormatPart :: Literal ( "abcd" . to_owned( ) ) ,
10351035 FormatPart :: Field {
10361036 field_name: "1" . to_owned( ) ,
1037- preconversion_spec : None ,
1037+ conversion_spec : None ,
10381038 format_spec: String :: new( ) ,
10391039 } ,
10401040 FormatPart :: Literal ( ":" . to_owned( ) ) ,
10411041 FormatPart :: Field {
10421042 field_name: "key" . to_owned( ) ,
1043- preconversion_spec : None ,
1043+ conversion_spec : None ,
10441044 format_spec: String :: new( ) ,
10451045 } ,
10461046 ] ,
@@ -1069,7 +1069,7 @@ mod tests {
10691069 FormatPart :: Literal ( "{" . to_owned( ) ) ,
10701070 FormatPart :: Field {
10711071 field_name: "key" . to_owned( ) ,
1072- preconversion_spec : None ,
1072+ conversion_spec : None ,
10731073 format_spec: String :: new( ) ,
10741074 } ,
10751075 FormatPart :: Literal ( "}ddfe" . to_owned( ) ) ,
0 commit comments