File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -458,6 +458,9 @@ impl<R: BufRead> BufferedReader<R> {
458
458
buf : & ' buf mut Vec < u8 > ,
459
459
position : & mut usize ,
460
460
) -> Result < Option < & ' buf [ u8 ] > > {
461
+ // search byte must be within the ascii range
462
+ debug_assert ! ( byte. is_ascii( ) ) ;
463
+
461
464
let mut read = 0 ;
462
465
let mut done = false ;
463
466
let start = buf. len ( ) ;
@@ -617,6 +620,9 @@ impl<R: BufRead> BufferedReader<R> {
617
620
/// Consume and discard one character if it matches the given byte. Return
618
621
/// true if it matched.
619
622
fn skip_one ( & mut self , byte : u8 , position : & mut usize ) -> Result < bool > {
623
+ // search byte must be within the ascii range
624
+ debug_assert ! ( byte. is_ascii( ) ) ;
625
+
620
626
match self . peek_one ( ) ? {
621
627
Some ( b) if b == byte => {
622
628
* position += 1 ;
Original file line number Diff line number Diff line change @@ -378,6 +378,9 @@ impl<'buf> InnerReader for SliceReader<'buf> {
378
378
/// Private reading functions for a [`SliceReader`].
379
379
impl < ' buf > SliceReader < ' buf > {
380
380
fn read_bytes_until ( & mut self , byte : u8 , position : & mut usize ) -> Result < Option < & ' buf [ u8 ] > > {
381
+ // search byte must be within the ascii range
382
+ debug_assert ! ( byte. is_ascii( ) ) ;
383
+
381
384
if self . 0 . is_empty ( ) {
382
385
return Ok ( None ) ;
383
386
}
@@ -448,6 +451,9 @@ impl<'buf> SliceReader<'buf> {
448
451
}
449
452
450
453
fn skip_one ( & mut self , byte : u8 , position : & mut usize ) -> Result < bool > {
454
+ // search byte must be within the ascii range
455
+ debug_assert ! ( byte. is_ascii( ) ) ;
456
+
451
457
if self . 0 . first ( ) == Some ( & byte) {
452
458
self . 0 = & self . 0 [ 1 ..] ;
453
459
* position += 1 ;
You can’t perform that action at this time.
0 commit comments