@@ -328,8 +328,7 @@ macro_rules! read_until_close {
328328 . read_bang_element( $buf, & mut $self. state. offset)
329329 $( . $await) ?
330330 {
331- Ok ( None ) => Ok ( Event :: Eof ) ,
332- Ok ( Some ( ( bang_type, bytes) ) ) => $self. state. emit_bang( bang_type, bytes) ,
331+ Ok ( ( bang_type, bytes) ) => $self. state. emit_bang( bang_type, bytes) ,
333332 Err ( e) => Err ( e) ,
334333 } ,
335334 // `</` - closing tag
@@ -790,11 +789,7 @@ trait XmlSource<'r, B> {
790789 /// - `position`: Will be increased by amount of bytes consumed
791790 ///
792791 /// [events]: crate::events::Event
793- fn read_bang_element (
794- & mut self ,
795- buf : B ,
796- position : & mut usize ,
797- ) -> Result < Option < ( BangType , & ' r [ u8 ] ) > > ;
792+ fn read_bang_element ( & mut self , buf : B , position : & mut usize ) -> Result < ( BangType , & ' r [ u8 ] ) > ;
798793
799794 /// Read input until XML element is closed by approaching a `>` symbol.
800795 /// Returns a buffer that contains a data between `<` and `>` or
@@ -1154,13 +1149,13 @@ mod test {
11541149 let mut input = b"![CDATA[]]>other content" . as_ref( ) ;
11551150 // ^= 11
11561151
1152+ let ( ty, bytes) = $source( & mut input)
1153+ . read_bang_element( buf, & mut position)
1154+ $( . $await) ?
1155+ . unwrap( ) ;
11571156 assert_eq!(
1158- $source( & mut input)
1159- . read_bang_element( buf, & mut position)
1160- $( . $await) ?
1161- . unwrap( )
1162- . map( |( ty, data) | ( ty, Bytes ( data) ) ) ,
1163- Some ( ( BangType :: CData , Bytes ( b"![CDATA[]]" ) ) )
1157+ ( ty, Bytes ( bytes) ) ,
1158+ ( BangType :: CData , Bytes ( b"![CDATA[]]" ) )
11641159 ) ;
11651160 assert_eq!( position, 11 ) ;
11661161 }
@@ -1175,13 +1170,13 @@ mod test {
11751170 let mut input = b"![CDATA[cdata]] ]>content]]>other content]]>" . as_ref( ) ;
11761171 // ^= 28
11771172
1173+ let ( ty, bytes) = $source( & mut input)
1174+ . read_bang_element( buf, & mut position)
1175+ $( . $await) ?
1176+ . unwrap( ) ;
11781177 assert_eq!(
1179- $source( & mut input)
1180- . read_bang_element( buf, & mut position)
1181- $( . $await) ?
1182- . unwrap( )
1183- . map( |( ty, data) | ( ty, Bytes ( data) ) ) ,
1184- Some ( ( BangType :: CData , Bytes ( b"![CDATA[cdata]] ]>content]]" ) ) )
1178+ ( ty, Bytes ( bytes) ) ,
1179+ ( BangType :: CData , Bytes ( b"![CDATA[cdata]] ]>content]]" ) )
11851180 ) ;
11861181 assert_eq!( position, 28 ) ;
11871182 }
@@ -1300,13 +1295,13 @@ mod test {
13001295 let mut input = b"!---->other content" . as_ref( ) ;
13011296 // ^= 6
13021297
1298+ let ( ty, bytes) = $source( & mut input)
1299+ . read_bang_element( buf, & mut position)
1300+ $( . $await) ?
1301+ . unwrap( ) ;
13031302 assert_eq!(
1304- $source( & mut input)
1305- . read_bang_element( buf, & mut position)
1306- $( . $await) ?
1307- . unwrap( )
1308- . map( |( ty, data) | ( ty, Bytes ( data) ) ) ,
1309- Some ( ( BangType :: Comment , Bytes ( b"!----" ) ) )
1303+ ( ty, Bytes ( bytes) ) ,
1304+ ( BangType :: Comment , Bytes ( b"!----" ) )
13101305 ) ;
13111306 assert_eq!( position, 6 ) ;
13121307 }
@@ -1318,13 +1313,13 @@ mod test {
13181313 let mut input = b"!--->comment<--->other content" . as_ref( ) ;
13191314 // ^= 17
13201315
1316+ let ( ty, bytes) = $source( & mut input)
1317+ . read_bang_element( buf, & mut position)
1318+ $( . $await) ?
1319+ . unwrap( ) ;
13211320 assert_eq!(
1322- $source( & mut input)
1323- . read_bang_element( buf, & mut position)
1324- $( . $await) ?
1325- . unwrap( )
1326- . map( |( ty, data) | ( ty, Bytes ( data) ) ) ,
1327- Some ( ( BangType :: Comment , Bytes ( b"!--->comment<---" ) ) )
1321+ ( ty, Bytes ( bytes) ) ,
1322+ ( BangType :: Comment , Bytes ( b"!--->comment<---" ) )
13281323 ) ;
13291324 assert_eq!( position, 17 ) ;
13301325 }
@@ -1379,13 +1374,13 @@ mod test {
13791374 let mut input = b"!DOCTYPE>other content" . as_ref( ) ;
13801375 // ^= 9
13811376
1377+ let ( ty, bytes) = $source( & mut input)
1378+ . read_bang_element( buf, & mut position)
1379+ $( . $await) ?
1380+ . unwrap( ) ;
13821381 assert_eq!(
1383- $source( & mut input)
1384- . read_bang_element( buf, & mut position)
1385- $( . $await) ?
1386- . unwrap( )
1387- . map( |( ty, data) | ( ty, Bytes ( data) ) ) ,
1388- Some ( ( BangType :: DocType , Bytes ( b"!DOCTYPE" ) ) )
1382+ ( ty, Bytes ( bytes) ) ,
1383+ ( BangType :: DocType , Bytes ( b"!DOCTYPE" ) )
13891384 ) ;
13901385 assert_eq!( position, 9 ) ;
13911386 }
@@ -1453,13 +1448,13 @@ mod test {
14531448 let mut input = b"!doctype>other content" . as_ref( ) ;
14541449 // ^= 9
14551450
1451+ let ( ty, bytes) = $source( & mut input)
1452+ . read_bang_element( buf, & mut position)
1453+ $( . $await) ?
1454+ . unwrap( ) ;
14561455 assert_eq!(
1457- $source( & mut input)
1458- . read_bang_element( buf, & mut position)
1459- $( . $await) ?
1460- . unwrap( )
1461- . map( |( ty, data) | ( ty, Bytes ( data) ) ) ,
1462- Some ( ( BangType :: DocType , Bytes ( b"!doctype" ) ) )
1456+ ( ty, Bytes ( bytes) ) ,
1457+ ( BangType :: DocType , Bytes ( b"!doctype" ) )
14631458 ) ;
14641459 assert_eq!( position, 9 ) ;
14651460 }
0 commit comments