File tree 3 files changed +7
-9
lines changed
3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -202,13 +202,12 @@ macro_rules! impl_buffered_source {
202
202
}
203
203
}
204
204
205
- $( $async) ? fn skip_one( & mut self , byte: u8 , position : & mut usize ) -> Result <bool > {
205
+ $( $async) ? fn skip_one( & mut self , byte: u8 ) -> Result <bool > {
206
206
// search byte must be within the ascii range
207
207
debug_assert!( byte. is_ascii( ) ) ;
208
208
209
209
match self . peek_one( ) $( . $await) ? ? {
210
210
Some ( b) if b == byte => {
211
- * position += 1 ;
212
211
self $( . $reader) ? . consume( 1 ) ;
213
212
Ok ( true )
214
213
}
@@ -219,8 +218,7 @@ macro_rules! impl_buffered_source {
219
218
$( $async) ? fn peek_one( & mut self ) -> Result <Option <u8 >> {
220
219
loop {
221
220
break match self $( . $reader) ? . fill_buf( ) $( . $await) ? {
222
- Ok ( n) if n. is_empty( ) => Ok ( None ) ,
223
- Ok ( n) => Ok ( Some ( n[ 0 ] ) ) ,
221
+ Ok ( n) => Ok ( n. first( ) . cloned( ) ) ,
224
222
Err ( ref e) if e. kind( ) == io:: ErrorKind :: Interrupted => continue ,
225
223
Err ( e) => Err ( Error :: Io ( e. into( ) ) ) ,
226
224
} ;
Original file line number Diff line number Diff line change @@ -279,7 +279,8 @@ macro_rules! read_until_open {
279
279
}
280
280
281
281
// If we already at the `<` symbol, do not try to return an empty Text event
282
- if $reader. skip_one( b'<' , & mut $self. state. offset) $( . $await) ? ? {
282
+ if $reader. skip_one( b'<' ) $( . $await) ? ? {
283
+ $self. state. offset += 1 ;
283
284
$self. state. state = ParseState :: OpenedTag ;
284
285
// Pass $buf to the next next iteration of parsing loop
285
286
return Ok ( Err ( $buf) ) ;
@@ -889,8 +890,8 @@ trait XmlSource<'r, B> {
889
890
/// `true` if it matched.
890
891
///
891
892
/// # Parameters
892
- /// - `position `: Will be increased by 1 if byte is matched
893
- fn skip_one ( & mut self , byte : u8 , position : & mut usize ) -> Result < bool > ;
893
+ /// - `byte `: Character to skip
894
+ fn skip_one ( & mut self , byte : u8 ) -> Result < bool > ;
894
895
895
896
/// Return one character without consuming it, so that future `read_*` calls
896
897
/// will still include it. On EOF, return `None`.
Original file line number Diff line number Diff line change @@ -322,12 +322,11 @@ impl<'a> XmlSource<'a, ()> for &'a [u8] {
322
322
Ok ( ( ) )
323
323
}
324
324
325
- fn skip_one ( & mut self , byte : u8 , position : & mut usize ) -> Result < bool > {
325
+ fn skip_one ( & mut self , byte : u8 ) -> Result < bool > {
326
326
// search byte must be within the ascii range
327
327
debug_assert ! ( byte. is_ascii( ) ) ;
328
328
if self . first ( ) == Some ( & byte) {
329
329
* self = & self [ 1 ..] ;
330
- * position += 1 ;
331
330
Ok ( true )
332
331
} else {
333
332
Ok ( false )
You can’t perform that action at this time.
0 commit comments