74
74
{
75
75
/// Deserializer used to deserialize sequence items
76
76
de : & ' a mut Deserializer < ' de , R > ,
77
- /// Filter that determines whether a tag is a part of this sequence.
78
- ///
79
- /// When feature `overlapped-lists` is not activated, iteration will stop
80
- /// when found a tag that does not pass this filter.
81
- ///
82
- /// When feature `overlapped-lists` is activated, all tags, that not pass
83
- /// this check, will be skipped.
84
- filter : TagFilter < ' de > ,
85
-
86
- /// Checkpoint after which all skipped events should be returned. All events,
87
- /// that was skipped before creating this checkpoint, will still stay buffered
88
- /// and will not be returned
89
- #[ cfg( feature = "overlapped-lists" ) ]
90
- checkpoint : usize ,
91
77
}
92
78
93
79
impl < ' a , ' de , R > TopLevelSeqAccess < ' de , ' a , R >
96
82
{
97
83
/// Creates a new accessor to a top-level sequence of XML elements.
98
84
pub fn new ( de : & ' a mut Deserializer < ' de , R > ) -> Result < Self , DeError > {
99
- let filter = if let DeEvent :: Start ( e) = de. peek ( ) ? {
100
- // Clone is cheap if event borrows from the input
101
- TagFilter :: Include ( e. clone ( ) )
102
- } else {
103
- TagFilter :: Exclude ( & [ ] )
104
- } ;
105
- Ok ( Self {
106
- #[ cfg( feature = "overlapped-lists" ) ]
107
- checkpoint : de. skip_checkpoint ( ) ,
108
-
109
- de,
110
- filter,
111
- } )
112
- }
113
- }
114
-
115
- #[ cfg( feature = "overlapped-lists" ) ]
116
- impl < ' de , ' a , R > Drop for TopLevelSeqAccess < ' de , ' a , R >
117
- where
118
- R : XmlRead < ' de > ,
119
- {
120
- fn drop ( & mut self ) {
121
- self . de . start_replay ( self . checkpoint ) ;
85
+ Ok ( Self { de } )
122
86
}
123
87
}
124
88
@@ -132,24 +96,11 @@ where
132
96
where
133
97
T : DeserializeSeed < ' de > ,
134
98
{
135
- let decoder = self . de . reader . decoder ( ) ;
136
- loop {
137
- break match self . de . peek ( ) ? {
138
- // If we see a tag that we not interested, skip it
139
- #[ cfg( feature = "overlapped-lists" ) ]
140
- DeEvent :: Start ( e) if !self . filter . is_suitable ( e, decoder) ? => {
141
- self . de . skip ( ) ?;
142
- continue ;
143
- }
144
- // Stop iteration when list elements ends
145
- #[ cfg( not( feature = "overlapped-lists" ) ) ]
146
- DeEvent :: Start ( e) if !self . filter . is_suitable ( e, decoder) ? => Ok ( None ) ,
147
- DeEvent :: End ( _) => Ok ( None ) ,
148
- DeEvent :: Eof => Ok ( None ) ,
99
+ match self . de . peek ( ) ? {
100
+ DeEvent :: Eof => Ok ( None ) ,
149
101
150
- // Start(tag), Text, CData
151
- _ => seed. deserialize ( & mut * self . de ) . map ( Some ) ,
152
- } ;
102
+ // Start(tag), End(tag), Text, CData
103
+ _ => seed. deserialize ( & mut * self . de ) . map ( Some ) ,
153
104
}
154
105
}
155
106
}
0 commit comments