/// Attempts to get the next token from the file. Returns `None` if the
/// inner iterator has been exhausted.
Attempts to get the next token from the file. Returns `None` if the
inner iterator has been exhausted.
Attempts to get the next token from the file . Returns ` None ` if the inner iterator has been exhausted .
fn try_next(&mut self) -> Option<OffNext<'a>> {
        let (mut idx, mut c) = self.iter.next()?;
        let init_idx = idx;
        let mut end_idx = init_idx;
        loop {
            match c {
                // The start of a comment.
                '#' => {
                    self.comment = true;
                    self.position.next();
                }
                // End lines also end comments.
                '\n' => {
                    self.comment = false;
                    self.position.next_line();
                }
                // We just advance the position otherwise.
                _ => self.position.next(),
            }
            // If we're in the middle of a comment, or we found a whitespace,
            // then whatever token we were reading has ended.
            if self.comment || c.is_whitespace() {
                break;
            }
            // Advances the iterator.
            end_idx = idx;
            if let Some((new_idx, new_c)) = self.iter.next() {
                idx = new_idx;
                c = new_c;
            } else {
                // We do this so that it seems ilke we read something at the end.
                idx += 1;
                break;
            }
        }
        // If we immediately broke out of the loop, this means we just read a
        // single character in a comment or a whitespace. That is, garbage.
        Some(if init_idx == idx {
            OffNext::Garbage
        } else {
            OffNext::Token(&self.src[init_idx..=end_idx])
        })
    }
fn try_next ( & mut self ) -> Option < OffNext < ' a > > { let ( mut idx , mut c ) = self . iter . next ( ) ? ; let init_idx = idx ; let mut end_idx = init_idx ; loop { match c { // The start of a comment. '#' => { self . comment = true ; self . position . next ( ) ; } // End lines also end comments. '\n' => { self . comment = false ; self . position . next_line ( ) ; } // We just advance the position otherwise. _ => self . position . next ( ) , } // If we're in the middle of a comment, or we found a whitespace, // then whatever token we were reading has ended. if self . comment || c . is_whitespace ( ) { break ; } // Advances the iterator. end_idx = idx ; if let Some ( ( new_idx , new_c ) ) = self . iter . next ( ) { idx = new_idx ; c = new_c ; } else { // We do this so that it seems ilke we read something at the end. idx += 1 ; break ; } } // If we immediately broke out of the loop, this means we just read a // single character in a comment or a whitespace. That is, garbage. Some ( if init_idx == idx { OffNext :: Garbage } else { OffNext :: Token ( & self . src [ init_idx ..= end_idx ] ) } ) }
Attempts to get the next token from the file.
Attempts to get the next token from the file .
&mut self