Struct AttachedToken
pub struct AttachedToken(pub TokenWithSpan);Expand description
A wrapper over TokenWithSpans that ignores the token and source
location in comparisons and hashing.
This type is used when the token and location is not relevant for semantics, but is still needed for accurate source location tracking, for example, in the nodes in the ast module.
Note: All AttachedTokens are equal.
ยงExamples
Same token, different location are equal
// commas @ line 1, column 10
let tok1 = TokenWithLocation::new(
Token::Comma,
Span::new(Location::new(1, 10), Location::new(1, 11)),
);
// commas @ line 2, column 20
let tok2 = TokenWithLocation::new(
Token::Comma,
Span::new(Location::new(2, 20), Location::new(2, 21)),
);
assert_ne!(tok1, tok2); // token with locations are *not* equal
assert_eq!(AttachedToken(tok1), AttachedToken(tok2)); // attached tokens areDifferent token, different location are equal ๐คฏ
// commas @ line 1, column 10
let tok1 = TokenWithLocation::new(
Token::Comma,
Span::new(Location::new(1, 10), Location::new(1, 11)),
);
// period @ line 2, column 20
let tok2 = TokenWithLocation::new(
Token::Period,
Span::new(Location::new(2, 10), Location::new(2, 21)),
);
assert_ne!(tok1, tok2); // token with locations are *not* equal
assert_eq!(AttachedToken(tok1), AttachedToken(tok2)); // attached tokens are// period @ line 2, column 20
Tuple Fieldsยง
ยง0: TokenWithSpanImplementationsยง
ยงimpl AttachedToken
impl AttachedToken
pub fn empty() -> AttachedToken
pub fn empty() -> AttachedToken
Return a new Empty AttachedToken
Trait Implementationsยง
ยงimpl Clone for AttachedToken
impl Clone for AttachedToken
ยงfn clone(&self) -> AttachedToken
fn clone(&self) -> AttachedToken
Returns a duplicate of the value. Read more
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreยงimpl Debug for AttachedToken
impl Debug for AttachedToken
ยงimpl From<AttachedToken> for TokenWithSpan
impl From<AttachedToken> for TokenWithSpan
ยงfn from(value: AttachedToken) -> TokenWithSpan
fn from(value: AttachedToken) -> TokenWithSpan
Converts to this type from the input type.
ยงimpl From<TokenWithSpan> for AttachedToken
impl From<TokenWithSpan> for AttachedToken
ยงfn from(value: TokenWithSpan) -> AttachedToken
fn from(value: TokenWithSpan) -> AttachedToken
Converts to this type from the input type.
ยงimpl Hash for AttachedToken
impl Hash for AttachedToken
ยงimpl Ord for AttachedToken
impl Ord for AttachedToken
ยงimpl PartialEq for AttachedToken
impl PartialEq for AttachedToken
ยงimpl PartialOrd for AttachedToken
impl PartialOrd for AttachedToken
ยงimpl Visit for AttachedToken
impl Visit for AttachedToken
ยงimpl VisitMut for AttachedToken
impl VisitMut for AttachedToken
fn visit<V>(&mut self, visitor: &mut V) -> ControlFlow<<V as VisitorMut>::Break>where
V: VisitorMut,
impl Eq for AttachedToken
Auto Trait Implementationsยง
impl Freeze for AttachedToken
impl RefUnwindSafe for AttachedToken
impl Send for AttachedToken
impl Sync for AttachedToken
impl Unpin for AttachedToken
impl UnwindSafe for AttachedToken
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,
ยงimpl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
ยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
ยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
ยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
ยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.ยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
ยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
ยงimpl<T> Instrument for T
impl<T> Instrument for T
ยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
ยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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