Struct Cursor
pub struct Cursor<'a> { /* private fields */ }
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() -> SelfCreates a cursor referencing a static empty TokenStream.
fn eof(self) -> boolChecks whether the cursor is currently pointing at the end of its valid scope.
fn ident(self) -> Option<(Ident, Cursor<'a>)>If the cursor is pointing at a
Ident, returns it along with a cursor pointing at the nextTokenTree.fn punct(self) -> Option<(Punct, Cursor<'a>)>If the cursor is pointing at a
Punct, returns it along with a cursor pointing at the nextTokenTree.fn literal(self) -> Option<(Literal, Cursor<'a>)>If the cursor is pointing at a
Literal, return it along with a cursor pointing at the nextTokenTree.fn lifetime(self) -> Option<(Lifetime, Cursor<'a>)>If the cursor is pointing at a
Lifetime, returns it along with a cursor pointing at the nextTokenTree.fn group(self, delim: Delimiter) -> Option<(Cursor<'a>, DelimSpan, Cursor<'a>)>If the cursor is pointing at a
Groupwith the given delimiter, returns a cursor into that group and one pointing to the nextTokenTree.fn any_group(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 nextTokenTree.fn token_stream(self) -> TokenStreamCopies all remaining tokens visible from this cursor into a
TokenStream.fn token_tree(self) -> Option<(TokenTree, Cursor<'a>)>If the cursor is pointing at a
TokenTree, returns it along with a cursor pointing at the nextTokenTree.Returns
Noneif the cursor has reached the end of its stream.This method does not treat
None-delimited groups as transparent, and will return aGroup(None, ..)if the cursor is looking at one.fn span(self) -> SpanReturns the
Spanof the current token, orSpan::call_site()if this cursor points to eof.fn prev_span(self) -> SpanReturns the
Spanof the token immediately prior to the position of this cursor, or of the current token if there is no previous one.
Trait Implementations
impl<'a> Clone for Cursor<'a>
fn clone(&self) -> Self
impl<'a> Copy for Cursor<'a>
impl<'a> Eq for Cursor<'a>
impl<'a> PartialEq for Cursor<'a>
fn eq(&self, other: &Self) -> bool
impl<'a> PartialOrd for Cursor<'a>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
Auto Trait Implementations
impl<'a> !Send for Cursor<'a>
impl<'a> !Sync for Cursor<'a>
impl<'a> Freeze for Cursor<'a>
impl<'a> RefUnwindSafe for Cursor<'a>
impl<'a> Unpin for Cursor<'a>
impl<'a> UnsafeUnpin for Cursor<'a>
impl<'a> UnwindSafe for Cursor<'a>
Blanket Implementations
impl<T> Any for Cursor<'a>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Cursor<'a>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Cursor<'a>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Cursor<'a>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Cursor<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Cursor<'a>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Cursor<'a>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Cursor<'a>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Cursor<'a>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>