pub struct TokenWithSpan {
pub token: Token,
pub span: Span,
}
Expand description
A Token with Span attached to it
This is used to track the location of a token in the input string
§Examples
// commas @ line 1, column 10
let tok1 = TokenWithSpan::new(
Token::Comma,
Span::new(Location::new(1, 10), Location::new(1, 11)),
);
assert_eq!(tok1, Token::Comma); // can compare the token
// commas @ line 2, column 20
let tok2 = TokenWithSpan::new(
Token::Comma,
Span::new(Location::new(2, 20), Location::new(2, 21)),
);
// same token but different locations are not equal
assert_ne!(tok1, tok2);
A Token together with its Span (location in the source).
The token value.
The span covering the token in the input.
Converts to this type from the input type.
Converts to this type from the input type.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
Tests less than (for self and other) and is used by the < operator. Read more
Tests less than or equal to (for self and other) and is used by the
<= operator. Read more
Tests greater than (for self and other) and is used by the >
operator. Read more
Tests greater than or equal to (for self and other) and is used by
the >= operator. Read more
Return the Span (the minimum and maximum Location) for this AST
node, by recursively combining the spans of its children.