Struct castle_input_cursor::Cursor
source · pub struct Cursor<R> { /* private fields */ }
Expand description
Cursor over the source code.
Implementations§
source§impl<R> Cursor<R>where
R: Read,
impl<R> Cursor<R>where
R: Read,
sourcepub fn peek_n(&mut self, n: u8) -> Result<u32, Error>
pub fn peek_n(&mut self, n: u8) -> Result<u32, Error>
Peeks the next n bytes, the maximum number of peeked bytes is 4 (n <= 4).
sourcepub fn peek_char(&mut self) -> Result<Option<u32>, Error>
pub fn peek_char(&mut self) -> Result<Option<u32>, Error>
Peeks the next UTF-8 character in u32 code point.
sourcepub fn next_is(&mut self, byte: u8) -> Result<bool>
pub fn next_is(&mut self, byte: u8) -> Result<bool>
Compares the byte passed in to the next byte, if they match true is returned and the buffer is incremented
sourcepub fn next_is_char_pred<F>(&mut self, pred: &F) -> Result<bool>where
F: Fn(u32) -> bool,
pub fn next_is_char_pred<F>(&mut self, pred: &F) -> Result<bool>where
F: Fn(u32) -> bool,
Applies the predicate to the next UTF-8 character and returns the result. Returns false if there is no next character, otherwise returns the result from the predicate on the ascii char
The buffer is not incremented.