pub struct Cursor<'a> { /* private fields */ }Expand description
Zero-copy immutable cursor over source text. Each parse step returns a new advanced cursor.
Implementations§
Source§impl<'a> Cursor<'a>
impl<'a> Cursor<'a>
pub fn new(src: &'a str, offset: u32) -> Self
pub fn rest(&self) -> &'a str
pub fn offset(&self) -> u32
pub fn is_empty(&self) -> bool
pub fn first(&self) -> Option<char>
pub fn starts_with(&self, s: &str) -> bool
pub fn span(&self) -> Span
Sourcepub fn span_to(&self, end: &Cursor<'_>) -> Span
pub fn span_to(&self, end: &Cursor<'_>) -> Span
Create a fallback::Span from this cursor to another.
Sourcepub fn slice_to(&self, end: Cursor<'_>) -> &'a str
pub fn slice_to(&self, end: Cursor<'_>) -> &'a str
Get a slice of text from the current cursor to the provided end.
Sourcepub fn advance_by(&self, n: usize) -> Self
pub fn advance_by(&self, n: usize) -> Self
Advance by n bytes, counting characters for the offset.
Sourcepub fn skip_while(&self, pred: impl FnMut(char) -> bool) -> Self
pub fn skip_while(&self, pred: impl FnMut(char) -> bool) -> Self
Advance while predicate holds on chars.
pub fn skip_whitespace(self) -> Self
Sourcepub fn is_line_doc(&self) -> bool
pub fn is_line_doc(&self) -> bool
True at a line doc comment: ///... (but not ////...) or //!....
Sourcepub fn is_block_doc(&self) -> bool
pub fn is_block_doc(&self) -> bool
True at a block doc comment: /**... (but not /***//**/) or /*!....
Sourcepub fn doc_comment(&self) -> Option<(Self, bool, String)>
pub fn doc_comment(&self) -> Option<(Self, bool, String)>
If positioned at a doc comment, return (cursor after it, is_inner, text).
pub fn skip_comment(&self) -> Option<Self>
Trait Implementations§
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> UnsafeUnpin 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