Skip to main content

Cursor

Struct Cursor 

Source
pub struct Cursor<'a> { /* private fields */ }
Expand description

A source-aware cursor over one Directive’s tokens during setup.

Implementations§

Source§

impl<'a> Cursor<'a>

Source

pub fn has_next(&self) -> bool

Whether another token remains after the current token.

Source

pub fn new(file: &'a str, tokens: &'a [Token]) -> Self

Start before the first token.

Source

pub fn next(&mut self) -> bool

Load the next token without regard to line boundaries.

Source

pub fn next_arg(&mut self) -> bool

Load the next token only if it is on the current line.

Source

pub fn next_line(&mut self) -> bool

Load the next token only if it starts a new source line.

Source

pub fn next_block(&mut self) -> bool

Enter or continue a nested brace-delimited block.

Source

pub fn val(&self) -> &str

Current token text, or an empty string before the first token.

Source

pub fn file(&self) -> &str

Current source file, falling back to the initial filename.

Source

pub fn line(&self) -> usize

Current source line, or zero before the first token.

Source

pub fn args(&mut self, targets: &mut [&mut String]) -> bool

Fill targets with same-line arguments, leaving missing targets unchanged.

Source

pub fn remaining_args(&mut self) -> Vec<String>

Consume the remaining same-line arguments, stopping before an opening brace.

Source

pub fn error(&self, message: impl Into<String>) -> Error

Create an error at the current token.

Source

pub fn arg_err(&self) -> Error

Create the standard missing or unexpected argument error.

Auto Trait Implementations§

§

impl<'a> Forget for Cursor<'a>

§

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

§

impl<'a> Move 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.