Struct Cursor

struct Cursor<'a> { ... }

A cheaply copyable cursor into a TokenBuffer.

This cursor holds a shared reference into the immutable data which is used internally to represent a TokenStream, and can be efficiently manipulated and copied around.

An empty Cursor can be created directly, or one may create a TokenBuffer object and get a cursor to its first token with begin().

Implementations

impl<'a> Cursor<'a>

fn empty() -> Self

Creates a cursor referencing a static empty TokenStream.

fn eof(self: Self) -> bool

Checks whether the cursor is currently pointing at the end of its valid scope.

fn ident(self: Self) -> Option<(Ident, Cursor<'a>)>

If the cursor is pointing at a Ident, returns it along with a cursor pointing at the next TokenTree.

fn punct(self: Self) -> Option<(Punct, Cursor<'a>)>

If the cursor is pointing at a Punct, returns it along with a cursor pointing at the next TokenTree.

fn literal(self: Self) -> Option<(Literal, Cursor<'a>)>

If the cursor is pointing at a Literal, return it along with a cursor pointing at the next TokenTree.

fn lifetime(self: Self) -> Option<(Lifetime, Cursor<'a>)>

If the cursor is pointing at a Lifetime, returns it along with a cursor pointing at the next TokenTree.

fn group(self: Self, delim: Delimiter) -> Option<(Cursor<'a>, DelimSpan, Cursor<'a>)>

If the cursor is pointing at a Group with the given delimiter, returns a cursor into that group and one pointing to the next TokenTree.

fn any_group(self: Self) -> Option<(Cursor<'a>, Delimiter, DelimSpan, Cursor<'a>)>

If the cursor is pointing at a Group, returns a cursor into the group and one pointing to the next TokenTree.

fn token_stream(self: Self) -> TokenStream

Copies all remaining tokens visible from this cursor into a TokenStream.

fn token_tree(self: Self) -> Option<(TokenTree, Cursor<'a>)>

If the cursor is pointing at a TokenTree, returns it along with a cursor pointing at the next TokenTree.

Returns None if the cursor has reached the end of its stream.

This method does not treat None-delimited groups as transparent, and will return a Group(None, ..) if the cursor is looking at one.

fn span(self: Self) -> Span

Returns the Span of the current token, or Span::call_site() if this cursor points to eof.

impl<'a> Clone for Cursor<'a>

fn clone(self: &Self) -> Self

impl<'a> Copy for Cursor<'a>

impl<'a> Eq for Cursor<'a>

impl<'a> Freeze for Cursor<'a>

impl<'a> PartialEq for Cursor<'a>

fn eq(self: &Self, other: &Self) -> bool

impl<'a> PartialOrd for Cursor<'a>

fn partial_cmp(self: &Self, other: &Self) -> Option<Ordering>

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>

impl<T> Any for Cursor<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Cursor<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Cursor<'a>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Cursor<'a>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Cursor<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Cursor<'a>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Cursor<'a>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Cursor<'a>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Cursor<'a>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>