pub struct Spanned<T> {
pub inner: T,
pub span: Span,
}
Expand description
A thing attached to some Span
that tracks its origin in the macro invocation.
Fields§
§inner: T
The thing to which the Span
is attached.
span: Span
The Span
which is attache to the thing.
Implementations§
Source§impl Spanned<Syntax>
impl Spanned<Syntax>
Sourcepub fn to_token_stream_with<F>(&self, add_optional: &mut F) -> TokenStream
pub fn to_token_stream_with<F>(&self, add_optional: &mut F) -> TokenStream
Convenience function for converting a Spanned<Syntax>
into a TokenStream
via
Spanned::to_tokens_with
.
Sourcepub fn to_tokens_with<F>(&self, add_optional: &mut F, tokens: &mut TokenStream)
pub fn to_tokens_with<F>(&self, add_optional: &mut F, tokens: &mut TokenStream)
Convert a Spanned<Syntax>
into tokens and append them to the provided token stream, with a
predicate to determine whether or not optional syntax should be added or not.
The added optional syntax predicate is an FnMut
closure so that we can randomly choose to
add or not add optional trailing commas and similar during testing.
Source§impl Spanned<Target>
impl Spanned<Target>
Sourcepub fn to_token_stream_with_crate_name(
&self,
dialectic_crate: &Path,
) -> TokenStream
pub fn to_token_stream_with_crate_name( &self, dialectic_crate: &Path, ) -> TokenStream
Convert this Spanned<Target>
into a TokenStream
using a provided crate name when
referencing types from dialectic.
Sourcepub fn to_tokens_with_crate_name(
&self,
dialectic_crate: &Path,
tokens: &mut TokenStream,
)
pub fn to_tokens_with_crate_name( &self, dialectic_crate: &Path, tokens: &mut TokenStream, )
Convert this Spanned<Target>
into tokens and append them to the provided TokenStream
using a provided crate name when referencing types from dialectic.
Trait Implementations§
Source§impl Arbitrary for Spanned<Syntax>
Currently, we have a bit of a limitation on the arbitrary impl for syntax. The first part of
this is that it’s annoying to generate valid labels for lifetimes, so for now we’re using a
set of known valid lifetime names. The second is that generating valid Rust types is
somewhat nontrivial and the syn crate does not have a way to ask it to implement Arbitrary
for its Type
AST node. So currently we just use the unit type ()
wherever we may need to
place a type.
impl Arbitrary for Spanned<Syntax>
Currently, we have a bit of a limitation on the arbitrary impl for syntax. The first part of
this is that it’s annoying to generate valid labels for lifetimes, so for now we’re using a
set of known valid lifetime names. The second is that generating valid Rust types is
somewhat nontrivial and the syn crate does not have a way to ask it to implement Arbitrary
for its Type
AST node. So currently we just use the unit type ()
wherever we may need to
place a type.
Source§impl ToTokens for Spanned<Syntax>
impl ToTokens for Spanned<Syntax>
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Source§impl ToTokens for Spanned<Target>
impl ToTokens for Spanned<Target>
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
impl<T: Copy> Copy for Spanned<T>
Auto Trait Implementations§
impl<T> Freeze for Spanned<T>where
T: Freeze,
impl<T> RefUnwindSafe for Spanned<T>where
T: RefUnwindSafe,
impl<T> !Send for Spanned<T>
impl<T> !Sync for Spanned<T>
impl<T> Unpin for Spanned<T>where
T: Unpin,
impl<T> UnwindSafe for Spanned<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Span
covering the complete contents of this syntax tree
node, or Span::call_site()
if this node is empty.