@@ -619,7 +619,7 @@ where
619
619
_ => unreachable ! ( ) ,
620
620
}
621
621
} else {
622
- TagFilter :: Exclude ( self . map . fields )
622
+ TagFilter :: Exclude ( self . map . fields , self . map . has_text_field )
623
623
} ;
624
624
visitor. visit_seq ( MapValueSeqAccess {
625
625
#[ cfg( feature = "overlapped-lists" ) ]
@@ -860,15 +860,27 @@ enum TagFilter<'de> {
860
860
Include ( BytesStart < ' de > ) , //TODO: Need to store only name instead of a whole tag
861
861
/// A `SeqAccess` interested in tags with any name, except explicitly listed.
862
862
/// Excluded tags are used as struct field names and therefore should not
863
- /// fall into a `$value` category
864
- Exclude ( & ' static [ & ' static str ] ) ,
863
+ /// fall into a `$value` category.
864
+ ///
865
+ /// The `bool` represents the having of a `$text` special field in fields array.
866
+ /// It is used to exclude text events when `$text` fields is defined together with
867
+ /// `$value` fieldб and `$value` accepts sequence.
868
+ Exclude ( & ' static [ & ' static str ] , bool ) ,
865
869
}
866
870
867
871
impl < ' de > TagFilter < ' de > {
868
872
fn is_suitable ( & self , start : & BytesStart ) -> Result < bool , DeError > {
869
873
match self {
870
874
Self :: Include ( n) => Ok ( n. name ( ) == start. name ( ) ) ,
871
- Self :: Exclude ( fields) => not_in ( fields, start) ,
875
+ Self :: Exclude ( fields, _) => not_in ( fields, start) ,
876
+ }
877
+ }
878
+ const fn need_skip_text ( & self ) -> bool {
879
+ match self {
880
+ // If we look only for tags, we should skip any $text keys
881
+ Self :: Include ( _) => true ,
882
+ // If we look fo any data, we should exclude $text keys if it in the list
883
+ Self :: Exclude ( _, has_text_field) => * has_text_field,
872
884
}
873
885
}
874
886
}
@@ -953,9 +965,17 @@ where
953
965
self . map . de . skip ( ) ?;
954
966
continue ;
955
967
}
968
+ // Skip any text events if sequence expects only specific tag names
969
+ #[ cfg( feature = "overlapped-lists" ) ]
970
+ DeEvent :: Text ( _) if self . filter . need_skip_text ( ) => {
971
+ self . map . de . skip ( ) ?;
972
+ continue ;
973
+ }
956
974
// Stop iteration when list elements ends
957
975
#[ cfg( not( feature = "overlapped-lists" ) ) ]
958
976
DeEvent :: Start ( e) if !self . filter . is_suitable ( e) ? => Ok ( None ) ,
977
+ #[ cfg( not( feature = "overlapped-lists" ) ) ]
978
+ DeEvent :: Text ( _) if self . filter . need_skip_text ( ) => Ok ( None ) ,
959
979
960
980
// Stop iteration after reaching a closing tag
961
981
// The matching tag name is guaranteed by the reader
0 commit comments