Trait yap::TokenLocation

source ·
pub trait TokenLocation {
    // Required method
    fn offset(&self) -> usize;
}
Expand description

Calling Tokens::location() returns an object that implements this trait.

Required Methods§

source

fn offset(&self) -> usize

Return the current offset into the tokens at the point at which this object was created. Tokens::offset() is simply a shorthand for calling this method at the current location.

Example
use yap::{ Tokens, IntoTokens, TokenLocation };

let mut s = "abc".into_tokens();
assert_eq!(s.location().offset(), 0);
s.next();
assert_eq!(s.location().offset(), 1);
s.next();
assert_eq!(s.location().offset(), 2);

Implementors§