File tree Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -203,13 +203,12 @@ macro_rules! impl_buffered_source {
203
203
}
204
204
}
205
205
206
- $( $async) ? fn skip_one( & mut self , byte: u8 , position : & mut usize ) -> Result <bool > {
206
+ $( $async) ? fn skip_one( & mut self , byte: u8 ) -> Result <bool > {
207
207
// search byte must be within the ascii range
208
208
debug_assert!( byte. is_ascii( ) ) ;
209
209
210
210
match self . peek_one( ) $( . $await) ? ? {
211
211
Some ( b) if b == byte => {
212
- * position += 1 ;
213
212
self $( . $reader) ? . consume( 1 ) ;
214
213
Ok ( true )
215
214
}
@@ -220,8 +219,7 @@ macro_rules! impl_buffered_source {
220
219
$( $async) ? fn peek_one( & mut self ) -> Result <Option <u8 >> {
221
220
loop {
222
221
break match self $( . $reader) ? . fill_buf( ) $( . $await) ? {
223
- Ok ( n) if n. is_empty( ) => Ok ( None ) ,
224
- Ok ( n) => Ok ( Some ( n[ 0 ] ) ) ,
222
+ Ok ( n) => Ok ( n. first( ) . cloned( ) ) ,
225
223
Err ( ref e) if e. kind( ) == io:: ErrorKind :: Interrupted => continue ,
226
224
Err ( e) => Err ( Error :: Io ( e. into( ) ) ) ,
227
225
} ;
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) ) ;
@@ -883,8 +884,8 @@ trait XmlSource<'r, B> {
883
884
/// `true` if it matched.
884
885
///
885
886
/// # Parameters
886
- /// - `position `: Will be increased by 1 if byte is matched
887
- fn skip_one ( & mut self , byte : u8 , position : & mut usize ) -> Result < bool > ;
887
+ /// - `byte `: Character to skip
888
+ fn skip_one ( & mut self , byte : u8 ) -> Result < bool > ;
888
889
889
890
/// Return one character without consuming it, so that future `read_*` calls
890
891
/// will still include it. On EOF, return `None`.
Original file line number Diff line number Diff line change @@ -321,12 +321,11 @@ impl<'a> XmlSource<'a, ()> for &'a [u8] {
321
321
Ok ( ( ) )
322
322
}
323
323
324
- fn skip_one ( & mut self , byte : u8 , position : & mut usize ) -> Result < bool > {
324
+ fn skip_one ( & mut self , byte : u8 ) -> Result < bool > {
325
325
// search byte must be within the ascii range
326
326
debug_assert ! ( byte. is_ascii( ) ) ;
327
327
if self . first ( ) == Some ( & byte) {
328
328
* self = & self [ 1 ..] ;
329
- * position += 1 ;
330
329
Ok ( true )
331
330
} else {
332
331
Ok ( false )
You can’t perform that action at this time.
0 commit comments