pub struct Cursor<'a> { /* private fields */ }
Expand description
Abstraction over a character iterator.
Implementations§
Source§impl<'a> Cursor<'a>
impl<'a> Cursor<'a>
Sourcepub fn peek_two(&self) -> (Option<char>, Option<char>)
pub fn peek_two(&self) -> (Option<char>, Option<char>)
Peeks the next two characters without advancing the cursor.
Sourcepub fn bump_two(&mut self) -> (Option<char>, Option<char>)
pub fn bump_two(&mut self) -> (Option<char>, Option<char>)
Bumps the cursor and returns the next two characters.
Sourcepub fn skip_while(&mut self, predicate: fn(char) -> bool)
pub fn skip_while(&mut self, predicate: fn(char) -> bool)
Bumps the cursor while predicate
is true for the current character.
Notably, this method will not consume the first non-matching character. This is in
contrast with methods like Iterator::take_while
. This behavior is achieved by peeking
the next character to see if it matches before consuming it.
Auto Trait Implementations§
impl<'a> Freeze for Cursor<'a>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more