pub struct AttachedToken(pub TokenWithSpan);
Expand description
A wrapper over TokenWithSpan
s 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 are
Different 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: TokenWithSpan
Implementationsยง
Sourceยงimpl AttachedToken
impl AttachedToken
Sourcepub fn empty() -> AttachedToken
pub fn empty() -> AttachedToken
Return a new Empty AttachedToken
Trait Implementationsยง
Sourceยงimpl Clone for AttachedToken
impl Clone for AttachedToken
Sourceยงfn clone(&self) -> AttachedToken
fn clone(&self) -> AttachedToken
Returns a copy 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 moreSourceยงimpl Debug for AttachedToken
impl Debug for AttachedToken
Sourceยงimpl From<AttachedToken> for TokenWithSpan
impl From<AttachedToken> for TokenWithSpan
Sourceยงfn from(value: AttachedToken) -> TokenWithSpan
fn from(value: AttachedToken) -> TokenWithSpan
Converts to this type from the input type.
Sourceยงimpl From<TokenWithSpan> for AttachedToken
impl From<TokenWithSpan> for AttachedToken
Sourceยงfn from(value: TokenWithSpan) -> AttachedToken
fn from(value: TokenWithSpan) -> AttachedToken
Converts to this type from the input type.
Sourceยงimpl Hash for AttachedToken
impl Hash for AttachedToken
Sourceยงimpl Ord for AttachedToken
impl Ord for AttachedToken
Sourceยงfn cmp(&self, _: &AttachedToken) -> Ordering
fn cmp(&self, _: &AttachedToken) -> Ordering
1.21.0 ยท Sourceยงfn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Sourceยงimpl PartialEq for AttachedToken
impl PartialEq for AttachedToken
Sourceยงimpl PartialOrd for AttachedToken
impl PartialOrd for AttachedToken
Sourceยงimpl Visit for AttachedToken
impl Visit for AttachedToken
Sourceยง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> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
Sourceยงimpl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
Sourceยงtype Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
The
AlignTo*
type which aligns Self
to ALIGNMENT
.Sourceยงimpl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
Sourceยงtype Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
The
AlignTo*
type which aligns Self
to ALIGNMENT
.Sourceยงimpl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
Sourceยงimpl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
Sourceยงtype Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
The
AlignTo*
type which aligns Self
to ALIGNMENT
.Sourceยงimpl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
Sourceยงimpl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
Sourceยงtype Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
The
AlignTo*
type which aligns Self
to ALIGNMENT
.Sourceยงimpl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
Sourceยงtype Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
The
AlignTo*
type which aligns Self
to ALIGNMENT
.Sourceยงimpl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
Sourceยงimpl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
Sourceยงtype Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
The
AlignTo*
type which aligns Self
to ALIGNMENT
.Sourceยงimpl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
Sourceยงimpl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
Sourceยงtype Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
The
AlignTo*
type which aligns Self
to ALIGNMENT
.Sourceยงimpl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
Sourceยงtype Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
The
AlignTo*
type which aligns Self
to ALIGNMENT
.Sourceยงimpl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
Sourceยงimpl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
Sourceยงimpl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
Sourceยงtype Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
The
AlignTo*
type which aligns Self
to ALIGNMENT
.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ยงimpl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยง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 moreSourceยงimpl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
Sourceยงfn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
Converts a reference to an FFI-safe type
Sourceยงfn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
Converts an FFI-safe type to a reference
Sourceยงimpl<S> ROExtAcc for S
impl<S> ROExtAcc for S
Sourceยงfn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
Gets a reference to a field, determined by
offset
. Read moreSourceยงfn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
Gets a muatble reference to a field, determined by
offset
. Read moreSourceยงfn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
Gets a const pointer to a field,
the field is determined by
offset
. Read moreSourceยงfn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
Gets a mutable pointer to a field, determined by
offset
. Read moreSourceยงimpl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
Sourceยงfn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
Replaces a field (determined by
offset
) with value
,
returning the previous value of the field. Read moreSourceยงfn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
Sourceยงimpl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
Sourceยงfn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
Replaces a field (determined by
offset
) with value
,
returning the previous value of the field. Read moreSourceยงfn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
Sourceยงimpl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Sourceยงfn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Emulates the pipeline operator, allowing method syntax in more places. Read more
Sourceยงfn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
The same as
piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read moreSourceยงfn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
The same as
piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
.Sourceยงfn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
Mutates self using a closure taking self by mutable reference,
passing it along the method chain. Read more
Sourceยงfn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Observes the value of self, passing it along unmodified.
Useful in long method chains. Read more
Sourceยงfn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
Performs a reference to reference conversion with
AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read moreSourceยงimpl<This> TransmuteElement for Thiswhere
This: ?Sized,
impl<This> TransmuteElement for Thiswhere
This: ?Sized,
Sourceยงunsafe fn transmute_element<T>(self) -> Self::TransmutedPtrwhere
Self: CanTransmuteElement<T>,
unsafe fn transmute_element<T>(self) -> Self::TransmutedPtrwhere
Self: CanTransmuteElement<T>,
Transmutes the element type of this pointer.. Read more
Sourceยงimpl<T> TypeIdentity for Twhere
T: ?Sized,
impl<T> TypeIdentity for Twhere
T: ?Sized,
Sourceยงfn as_type_mut(&mut self) -> &mut Self::Type
fn as_type_mut(&mut self) -> &mut Self::Type
Converts a mutable reference back to the original type.
Sourceยงfn into_type_box(self: Box<Self>) -> Box<Self::Type>
fn into_type_box(self: Box<Self>) -> Box<Self::Type>
Converts a box back to the original type.
Sourceยงfn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
Converts an Arc back to the original type. Read more
Sourceยงfn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
Converts an Rc back to the original type. Read more
Sourceยงfn from_type_ref(this: &Self::Type) -> &Self
fn from_type_ref(this: &Self::Type) -> &Self
Converts a reference back to the original type.
Sourceยงfn from_type_mut(this: &mut Self::Type) -> &mut Self
fn from_type_mut(this: &mut Self::Type) -> &mut Self
Converts a mutable reference back to the original type.
Sourceยงfn from_type_box(this: Box<Self::Type>) -> Box<Self>
fn from_type_box(this: Box<Self::Type>) -> Box<Self>
Converts a box back to the original type.