@@ -2115,6 +2115,11 @@ impl<'i, R: XmlRead<'i>, E: EntityResolver> XmlReader<'i, R, E> {
21152115 }
21162116 }
21172117
2118+ /// Returns `true` if all events was consumed
2119+ fn is_empty ( & self ) -> bool {
2120+ matches ! ( self . lookahead, Ok ( PayloadEvent :: Eof ) )
2121+ }
2122+
21182123 /// Read next event and put it in lookahead, return the current lookahead
21192124 #[ inline( always) ]
21202125 fn next_impl ( & mut self ) -> Result < PayloadEvent < ' i > , DeError > {
@@ -2374,6 +2379,19 @@ where
23742379 }
23752380 }
23762381
2382+ /// Returns `true` if all events was consumed.
2383+ pub fn is_empty ( & self ) -> bool {
2384+ #[ cfg( feature = "overlapped-lists" ) ]
2385+ if self . read . is_empty ( ) {
2386+ return self . reader . is_empty ( ) ;
2387+ }
2388+ #[ cfg( not( feature = "overlapped-lists" ) ) ]
2389+ if self . peek . is_none ( ) {
2390+ return self . reader . is_empty ( ) ;
2391+ }
2392+ false
2393+ }
2394+
23772395 /// Set the maximum number of events that could be skipped during deserialization
23782396 /// of sequences.
23792397 ///
@@ -2895,7 +2913,11 @@ where
28952913 T : DeserializeSeed < ' de > ,
28962914 {
28972915 match self . peek ( ) ? {
2898- DeEvent :: Eof => Ok ( None ) ,
2916+ DeEvent :: Eof => {
2917+ // We need to consume event in order to self.is_empty() worked
2918+ self . next ( ) ?;
2919+ Ok ( None )
2920+ }
28992921
29002922 // Start(tag), End(tag), Text
29012923 _ => seed. deserialize ( & mut * * self ) . map ( Some ) ,
0 commit comments