pub struct Token {
pub kind: Kind,
pub value: Value,
pub pos: SrcPos,
pub comments: Option<Box<TokenComments>>,
}
Expand description
A Token
Fields§
§kind: Kind
§value: Value
§pos: SrcPos
§comments: Option<Box<TokenComments>>
Implementations§
source§impl Token
impl Token
pub fn kinds_error(&self, kinds: &[Kind]) -> Diagnostic
pub fn to_identifier_value(&self, id: TokenId) -> Result<Ident, Diagnostic>
pub fn to_character_value( &self, id: TokenId, ) -> Result<WithToken<u8>, Diagnostic>
pub fn to_bit_string( &self, id: TokenId, ) -> Result<WithToken<BitString>, Diagnostic>
pub fn to_abstract_literal( &self, id: TokenId, ) -> Result<WithToken<AbstractLiteral>, Diagnostic>
pub fn to_string_value( &self, id: TokenId, ) -> Result<WithToken<Latin1String>, Diagnostic>
pub fn to_operator_symbol( &self, id: TokenId, ) -> Result<WithToken<Operator>, Diagnostic>
sourcepub fn full_range(&self) -> Range
pub fn full_range(&self) -> Range
Returns the full range of this token, respecting any potential comments. Note that Token::pos only returns the position of the token itself.
sourcepub fn equal_format(&self, other: &Token) -> bool
pub fn equal_format(&self, other: &Token) -> bool
return true
when self
is equal to other
while ignoring all
changes that are attributed to their position in the source file
and all changes that only affect comments.
Trait Implementations§
impl StructuralPartialEq for Token
Auto Trait Implementations§
impl Freeze for Token
impl !RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl !UnwindSafe for Token
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more