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 @@ -202,13 +202,12 @@ macro_rules! impl_buffered_source {
202202 }
203203 }
204204
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 > {
206206 // search byte must be within the ascii range
207207 debug_assert!( byte. is_ascii( ) ) ;
208208
209209 match self . peek_one( ) $( . $await) ? ? {
210210 Some ( b) if b == byte => {
211- * position += 1 ;
212211 self $( . $reader) ? . consume( 1 ) ;
213212 Ok ( true )
214213 }
@@ -219,8 +218,7 @@ macro_rules! impl_buffered_source {
219218 $( $async) ? fn peek_one( & mut self ) -> Result <Option <u8 >> {
220219 loop {
221220 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( ) ) ,
224222 Err ( ref e) if e. kind( ) == io:: ErrorKind :: Interrupted => continue ,
225223 Err ( e) => Err ( Error :: Io ( e. into( ) ) ) ,
226224 } ;
Original file line number Diff line number Diff line change @@ -279,7 +279,8 @@ macro_rules! read_until_open {
279279 }
280280
281281 // 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 ;
283284 $self. state. state = ParseState :: OpenedTag ;
284285 // Pass $buf to the next next iteration of parsing loop
285286 return Ok ( Err ( $buf) ) ;
@@ -889,8 +890,8 @@ trait XmlSource<'r, B> {
889890 /// `true` if it matched.
890891 ///
891892 /// # 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 > ;
894895
895896 /// Return one character without consuming it, so that future `read_*` calls
896897 /// 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] {
322322 Ok ( ( ) )
323323 }
324324
325- fn skip_one ( & mut self , byte : u8 , position : & mut usize ) -> Result < bool > {
325+ fn skip_one ( & mut self , byte : u8 ) -> Result < bool > {
326326 // search byte must be within the ascii range
327327 debug_assert ! ( byte. is_ascii( ) ) ;
328328 if self . first ( ) == Some ( & byte) {
329329 * self = & self [ 1 ..] ;
330- * position += 1 ;
331330 Ok ( true )
332331 } else {
333332 Ok ( false )
You can’t perform that action at this time.
0 commit comments