@@ -626,9 +626,9 @@ impl FieldNamePart {
626
626
627
627
#[ derive( Debug , PartialEq ) ]
628
628
pub ( crate ) enum FieldType {
629
- AutoSpec ,
630
- IndexSpec ( usize ) ,
631
- KeywordSpec ( String ) ,
629
+ Auto ,
630
+ Index ( usize ) ,
631
+ Keyword ( String ) ,
632
632
}
633
633
634
634
#[ derive( Debug , PartialEq ) ]
@@ -646,11 +646,11 @@ impl FieldName {
646
646
}
647
647
648
648
let field_type = if first. is_empty ( ) {
649
- FieldType :: AutoSpec
649
+ FieldType :: Auto
650
650
} else if let Ok ( index) = first. parse :: < usize > ( ) {
651
- FieldType :: IndexSpec ( index)
651
+ FieldType :: Index ( index)
652
652
} else {
653
- FieldType :: KeywordSpec ( first)
653
+ FieldType :: Keyword ( first)
654
654
} ;
655
655
656
656
let mut parts = Vec :: new ( ) ;
@@ -846,7 +846,7 @@ impl FormatString {
846
846
let mut auto_argument_index: usize = 0 ;
847
847
let mut seen_index = false ;
848
848
self . format_internal ( vm, & mut |field_type| match field_type {
849
- FieldType :: AutoSpec => {
849
+ FieldType :: Auto => {
850
850
if seen_index {
851
851
return Err ( vm. new_value_error (
852
852
"cannot switch from manual field specification to automatic field numbering"
@@ -860,7 +860,7 @@ impl FormatString {
860
860
. cloned ( )
861
861
. ok_or_else ( || vm. new_index_error ( "tuple index out of range" . to_owned ( ) ) )
862
862
}
863
- FieldType :: IndexSpec ( index) => {
863
+ FieldType :: Index ( index) => {
864
864
if auto_argument_index != 0 {
865
865
return Err ( vm. new_value_error (
866
866
"cannot switch from automatic field numbering to manual field specification"
@@ -874,18 +874,18 @@ impl FormatString {
874
874
. cloned ( )
875
875
. ok_or_else ( || vm. new_index_error ( "tuple index out of range" . to_owned ( ) ) )
876
876
}
877
- FieldType :: KeywordSpec ( keyword) => arguments
877
+ FieldType :: Keyword ( keyword) => arguments
878
878
. get_optional_kwarg ( & keyword)
879
879
. ok_or_else ( || vm. new_key_error ( vm. new_str ( keyword. to_owned ( ) ) ) ) ,
880
880
} )
881
881
}
882
882
883
883
pub ( crate ) fn format_map ( & self , dict : & PyObjectRef , vm : & VirtualMachine ) -> PyResult < String > {
884
884
self . format_internal ( vm, & mut |field_type| match field_type {
885
- FieldType :: AutoSpec | FieldType :: IndexSpec ( _) => {
885
+ FieldType :: Auto | FieldType :: Index ( _) => {
886
886
Err ( vm. new_value_error ( "Format string contains positional fields" . to_owned ( ) ) )
887
887
}
888
- FieldType :: KeywordSpec ( keyword) => dict. get_item ( keyword, & vm) ,
888
+ FieldType :: Keyword ( keyword) => dict. get_item ( keyword, & vm) ,
889
889
} )
890
890
}
891
891
}
@@ -896,7 +896,7 @@ fn call_object_format(
896
896
preconversion_spec : Option < char > ,
897
897
format_spec : & str ,
898
898
) -> PyResult {
899
- let argument = match preconversion_spec. and_then ( |c| FormatPreconversor :: from_char ( c ) ) {
899
+ let argument = match preconversion_spec. and_then ( FormatPreconversor :: from_char) {
900
900
Some ( FormatPreconversor :: Str ) => vm. call_method ( & argument, "__str__" , vec ! [ ] ) ?,
901
901
Some ( FormatPreconversor :: Repr ) => vm. call_method ( & argument, "__repr__" , vec ! [ ] ) ?,
902
902
Some ( FormatPreconversor :: Ascii ) => vm. call_method ( & argument, "__repr__" , vec ! [ ] ) ?,
@@ -1126,28 +1126,28 @@ mod tests {
1126
1126
assert_eq ! (
1127
1127
FieldName :: parse( "" ) ,
1128
1128
Ok ( FieldName {
1129
- field_type: FieldType :: AutoSpec ,
1129
+ field_type: FieldType :: Auto ,
1130
1130
parts: Vec :: new( ) ,
1131
1131
} )
1132
1132
) ;
1133
1133
assert_eq ! (
1134
1134
FieldName :: parse( "0" ) ,
1135
1135
Ok ( FieldName {
1136
- field_type: FieldType :: IndexSpec ( 0 ) ,
1136
+ field_type: FieldType :: Index ( 0 ) ,
1137
1137
parts: Vec :: new( ) ,
1138
1138
} )
1139
1139
) ;
1140
1140
assert_eq ! (
1141
1141
FieldName :: parse( "key" ) ,
1142
1142
Ok ( FieldName {
1143
- field_type: FieldType :: KeywordSpec ( "key" . to_owned( ) ) ,
1143
+ field_type: FieldType :: Keyword ( "key" . to_owned( ) ) ,
1144
1144
parts: Vec :: new( ) ,
1145
1145
} )
1146
1146
) ;
1147
1147
assert_eq ! (
1148
1148
FieldName :: parse( "key.attr[0][string]" ) ,
1149
1149
Ok ( FieldName {
1150
- field_type: FieldType :: KeywordSpec ( "key" . to_owned( ) ) ,
1150
+ field_type: FieldType :: Keyword ( "key" . to_owned( ) ) ,
1151
1151
parts: vec![
1152
1152
FieldNamePart :: Attribute ( "attr" . to_owned( ) ) ,
1153
1153
FieldNamePart :: Index ( 0 ) ,
0 commit comments