@@ -2750,8 +2750,8 @@ where
2750
2750
where
2751
2751
V : Visitor < ' de > ,
2752
2752
{
2753
- for item in self . 0 . iter_mut ( ) {
2754
- if let Some ( ( key, value) ) = use_item ( item , variants) {
2753
+ for entry in self . 0 . iter_mut ( ) {
2754
+ if let Some ( ( key, value) ) = flat_map_take_entry ( entry , variants) {
2755
2755
return visitor. visit_enum ( EnumDeserializer :: new ( key, Some ( value) ) ) ;
2756
2756
}
2757
2757
}
@@ -2902,8 +2902,8 @@ where
2902
2902
where
2903
2903
T : DeserializeSeed < ' de > ,
2904
2904
{
2905
- for item in self . iter . by_ref ( ) {
2906
- if let Some ( ( key, content) ) = use_item ( item , self . fields ) {
2905
+ for entry in self . iter . by_ref ( ) {
2906
+ if let Some ( ( key, content) ) = flat_map_take_entry ( entry , self . fields ) {
2907
2907
self . pending_content = Some ( content) ;
2908
2908
return seed. deserialize ( ContentDeserializer :: new ( key) ) . map ( Some ) ;
2909
2909
}
@@ -2922,24 +2922,23 @@ where
2922
2922
}
2923
2923
}
2924
2924
2925
- /// Checks if first element of the specified pair matches one of the key from
2926
- /// `keys` parameter and if this is true, takes it from the option and returns.
2927
- /// Otherwise, or if `item` already empty, returns `None`.
2925
+ /// Claims one key-value pair from a FlatMapDeserializer's field buffer if the
2926
+ /// field name matches any of the recognized ones.
2928
2927
#[ cfg( any( feature = "std" , feature = "alloc" ) ) ]
2929
- fn use_item < ' de > (
2930
- item : & mut Option < ( Content < ' de > , Content < ' de > ) > ,
2931
- keys : & [ & str ] ,
2928
+ fn flat_map_take_entry < ' de > (
2929
+ entry : & mut Option < ( Content < ' de > , Content < ' de > ) > ,
2930
+ recognized : & [ & str ] ,
2932
2931
) -> Option < ( Content < ' de > , Content < ' de > ) > {
2933
- // items in the vector are nulled out when used. So we can only use
2934
- // an item if it's still filled in and if the field is one we care
2935
- // about .
2936
- let use_item = match * item {
2932
+ // Entries in the FlatMapDeserializer buffer are nulled out as they get
2933
+ // claimed for deserialization. We only use an entry if it is still present
2934
+ // and if the field is one recognized by the current data structure .
2935
+ let is_recognized = match entry {
2937
2936
None => false ,
2938
- Some ( ( ref c , _ ) ) => c . as_str ( ) . map_or ( false , |key| keys . contains ( & key ) ) ,
2937
+ Some ( ( k , _v ) ) => k . as_str ( ) . map_or ( false , |name| recognized . contains ( & name ) ) ,
2939
2938
} ;
2940
2939
2941
- if use_item {
2942
- item . take ( )
2940
+ if is_recognized {
2941
+ entry . take ( )
2943
2942
} else {
2944
2943
None
2945
2944
}
0 commit comments