@@ -611,7 +611,7 @@ where
611
611
_ => unreachable ! ( ) ,
612
612
}
613
613
} else {
614
- TagFilter :: Exclude ( self . map . fields )
614
+ TagFilter :: Exclude ( self . map . fields , self . map . has_text_field )
615
615
} ;
616
616
visitor. visit_seq ( MapValueSeqAccess {
617
617
#[ cfg( feature = "overlapped-lists" ) ]
@@ -852,15 +852,27 @@ enum TagFilter<'de> {
852
852
Include ( BytesStart < ' de > ) , //TODO: Need to store only name instead of a whole tag
853
853
/// A `SeqAccess` interested in tags with any name, except explicitly listed.
854
854
/// Excluded tags are used as struct field names and therefore should not
855
- /// fall into a `$value` category
856
- Exclude ( & ' static [ & ' static str ] ) ,
855
+ /// fall into a `$value` category.
856
+ ///
857
+ /// The `bool` represents the having of a `$text` special field in fields array.
858
+ /// It is used to exclude text events when `$text` fields is defined together with
859
+ /// `$value` fieldб and `$value` accepts sequence.
860
+ Exclude ( & ' static [ & ' static str ] , bool ) ,
857
861
}
858
862
859
863
impl < ' de > TagFilter < ' de > {
860
864
fn is_suitable ( & self , start : & BytesStart ) -> Result < bool , DeError > {
861
865
match self {
862
866
Self :: Include ( n) => Ok ( n. name ( ) == start. name ( ) ) ,
863
- Self :: Exclude ( fields) => not_in ( fields, start) ,
867
+ Self :: Exclude ( fields, _) => not_in ( fields, start) ,
868
+ }
869
+ }
870
+ const fn need_skip_text ( & self ) -> bool {
871
+ match self {
872
+ // If we look only for tags, we should skip any $text keys
873
+ Self :: Include ( _) => true ,
874
+ // If we look fo any data, we should exclude $text keys if it in the list
875
+ Self :: Exclude ( _, has_text_field) => * has_text_field,
864
876
}
865
877
}
866
878
}
@@ -944,9 +956,17 @@ where
944
956
self . map . de . skip ( ) ?;
945
957
continue ;
946
958
}
959
+ // Skip any text events if sequence expects only specific tag names
960
+ #[ cfg( feature = "overlapped-lists" ) ]
961
+ DeEvent :: Text ( _) if self . filter . need_skip_text ( ) => {
962
+ self . map . de . skip ( ) ?;
963
+ continue ;
964
+ }
947
965
// Stop iteration when list elements ends
948
966
#[ cfg( not( feature = "overlapped-lists" ) ) ]
949
967
DeEvent :: Start ( e) if !self . filter . is_suitable ( e) ? => Ok ( None ) ,
968
+ #[ cfg( not( feature = "overlapped-lists" ) ) ]
969
+ DeEvent :: Text ( _) if self . filter . need_skip_text ( ) => Ok ( None ) ,
950
970
951
971
// Stop iteration after reaching a closing tag
952
972
// The matching tag name is guaranteed by the reader
0 commit comments