Trait yap::TokenLocation
source · Expand description
Calling Tokens::location()
returns an object that implements this trait.
Required Methods§
sourcefn offset(&self) -> usize
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);