[−][src]Struct rustc_lexer::cursor::Cursor

pub(crate) struct Cursor<'a> {
    initial_len: usize,
    chars: Chars<'a>,
    prev: char,
}

Peekable iterator over a char sequence.

Next characters can be peeked via nth_char method, and position can be shifted forward via bump method.

Fields

initial_len: usizechars: Chars<'a>prev: char

Implementations

impl<'a> Cursor<'a>[src]

pub(crate) fn new(input: &'a str) -> Cursor<'a>[src]

pub(crate) fn prev(&self) -> char[src]

Returns the last eaten symbol (or '\0' in release builds). (For debug assertions only.)

pub(in cursor) fn nth_char(
    &self,
    n: usize
) -> char
[src]

Returns nth character relative to the current cursor position. If requested position doesn't exist, EOF_CHAR is returned. However, getting EOF_CHAR doesn't always mean actual end of file, it should be checked with is_eof method.

pub(crate) fn first(&self) -> char[src]

Peeks the next symbol from the input stream without consuming it.

pub(crate) fn second(&self) -> char[src]

Peeks the second symbol from the input stream without consuming it.

pub(crate) fn is_eof(&self) -> bool[src]

Checks if there is nothing more to consume.

pub(crate) fn len_consumed(&self) -> usize[src]

Returns amount of already consumed symbols.

pub(in cursor) fn chars(
    &self
) -> Chars<'a>
[src]

Returns a Chars iterator over the remaining characters.

pub(crate) fn bump(&mut self) -> Option<char>[src]

Moves to the next character.

impl<'_> Cursor<'_>[src]

pub(crate) fn advance_token(&mut self) -> Token[src]

Parses a token from the input string.

pub(crate) fn line_comment(&mut self) -> TokenKind[src]

pub(crate) fn block_comment(&mut self) -> TokenKind[src]

pub(crate) fn whitespace(&mut self) -> TokenKind[src]

pub(crate) fn raw_ident(&mut self) -> TokenKind[src]

pub(crate) fn ident(&mut self) -> TokenKind[src]

pub(crate) fn number(&mut self, first_digit: char) -> LiteralKind[src]

pub(crate) fn lifetime_or_char(&mut self) -> TokenKind[src]

pub(crate) fn single_quoted_string(&mut self) -> bool[src]

pub(crate) fn double_quoted_string(&mut self) -> bool[src]

Eats double-quoted string and returns true if string is terminated.

pub(crate) fn raw_double_quoted_string(
    &mut self,
    prefix_len: usize
) -> (u16, Option<RawStrError>)
[src]

Eats the double-quoted string and returns n_hashes and an error if encountered.

pub(crate) fn raw_string_unvalidated(
    &mut self,
    prefix_len: usize
) -> (usize, Option<RawStrError>)
[src]

pub(crate) fn eat_decimal_digits(&mut self) -> bool[src]

pub(crate) fn eat_hexadecimal_digits(&mut self) -> bool[src]

pub(crate) fn eat_float_exponent(&mut self) -> bool[src]

Eats the float exponent. Returns true if at least one digit was met, and returns false otherwise.

pub(crate) fn eat_literal_suffix(&mut self)[src]

pub(crate) fn eat_identifier(&mut self)[src]

pub(crate) fn eat_while(&mut self, predicate: impl FnMut(char) -> bool)[src]

Eats symbols while predicate returns true or until the end of file is reached.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Cursor<'a>

impl<'a> Send for Cursor<'a>

impl<'a> Sync for Cursor<'a>

impl<'a> Unpin for Cursor<'a>

impl<'a> UnwindSafe for Cursor<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.