[−][src]Struct full_moon::tokenizer::TokenReference
A reference to a token used by Ast's.
Dereferences to a Token
Methods
impl<'a> TokenReference<'a>
[src]
pub fn new(
leading_trivia: Vec<Token<'a>>,
token: Token<'a>,
trailing_trivia: Vec<Token<'a>>
) -> Self
[src]
leading_trivia: Vec<Token<'a>>,
token: Token<'a>,
trailing_trivia: Vec<Token<'a>>
) -> Self
Creates a TokenReference from leading/trailing trivia as well as the leading token
pub fn symbol(text: &str) -> Result<Self, TokenizerErrorType>
[src]
Returns a symbol with the leading and trailing whitespace Only whitespace is supported
let symbol = TokenReference::symbol("\nreturn ")?; assert_eq!(symbol.leading_trivia().next().unwrap().to_string(), "\n"); assert_eq!(symbol.token().token_type(), &TokenType::Symbol { symbol: Symbol::Return, }); assert_eq!(symbol.trailing_trivia().next().unwrap().to_string(), " "); assert!(TokenReference::symbol("isnt whitespace").is_err()); assert!(TokenReference::symbol(" notasymbol ").is_err());
pub fn token(&self) -> &Token<'a>
[src]
Returns the inner Token
pub fn leading_trivia(&self) -> impl Iterator<Item = &Token<'a>>
[src]
Returns the leading trivia
pub fn trailing_trivia(&self) -> impl Iterator<Item = &Token<'a>>
[src]
Returns the trailing trivia
pub fn with_token(&self, token: Token<'a>) -> Self
[src]
Creates a clone of the current TokenReference with the new inner token, preserving trivia.
Methods from Deref<Target = Token<'a>>
pub fn start_position(&self) -> Position
[src]
The position a token begins at
pub fn end_position(&self) -> Position
[src]
The position a token ends at
pub fn token_type(&self) -> &TokenType<'a>
[src]
The type of token as well as the data needed to represent it
If you don't need any other information, use token_kind
instead.
pub fn token_kind(&self) -> TokenKind
[src]
The kind of token with no additional data.
If you need any information such as idenitfier names, use token_type
instead.
Trait Implementations
impl<'a, '_> Borrow<Token<'a>> for &'_ TokenReference<'a>
[src]
impl<'a> Clone for TokenReference<'a>
[src]
fn clone(&self) -> TokenReference<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a> Debug for TokenReference<'a>
[src]
impl<'a> Deref for TokenReference<'a>
[src]
type Target = Token<'a>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl<'de: 'a, 'a> Deserialize<'de> for TokenReference<'a>
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<'a> Display for TokenReference<'a>
[src]
impl<'a> Eq for TokenReference<'a>
[src]
impl<'a> Node<'a> for TokenReference<'a>
[src]
fn start_position(&self) -> Option<Position>
[src]
fn end_position(&self) -> Option<Position>
[src]
fn similar(&self, other: &Self) -> bool
[src]
fn tokens<'b>(&'b self) -> Tokens<'a, 'b>
[src]
fn range(&self) -> Option<(Position, Position)>
[src]
fn surrounding_trivia<'b>(
&'b self
) -> (Vec<Cow<'b, Token<'ast>>>, Vec<Cow<'b, Token<'ast>>>)
[src]
&'b self
) -> (Vec<Cow<'b, Token<'ast>>>, Vec<Cow<'b, Token<'ast>>>)
impl<'a> Ord for TokenReference<'a>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a> Owned for TokenReference<'a>
[src]
type Owned = TokenReference<'static>
What an owned version of the object looks like. Usually contains a 'static
lifetime.
fn owned(&self) -> Self::Owned
[src]
impl<'a> PartialEq<TokenReference<'a>> for TokenReference<'a>
[src]
impl<'a> PartialOrd<TokenReference<'a>> for TokenReference<'a>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> Serialize for TokenReference<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for TokenReference<'a>
impl<'a> Send for TokenReference<'a>
impl<'a> Sync for TokenReference<'a>
impl<'a> Unpin for TokenReference<'a>
impl<'a> UnwindSafe for TokenReference<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,