pub struct Quote { /* private fields */ }
Expand description
Buffer for quasi quotting.
Implementations
sourceimpl Quote
impl Quote
pub fn new<S: Respan + 'static>(span: S) -> Self
sourcepub fn new_call_site() -> Self
pub fn new_call_site() -> Self
Shorthand for
ⓘ
Quote::new(Span::call_site())
sourcepub fn from_tokens(tokens: &dyn ToTokens) -> Self
pub fn from_tokens(tokens: &dyn ToTokens) -> Self
Shorthand for
ⓘ
Quote::new(tokens.first_last())
sourcepub fn from_tokens_or<T: ToTokens>(
tokens: &Option<T>,
default_span: Span
) -> Self
pub fn from_tokens_or<T: ToTokens>(
tokens: &Option<T>,
default_span: Span
) -> Self
Shorthand for
ⓘ
tokens
.as_ref()
.map(|tokens| Quote::from_tokens(tokens))
.unwrap_or_else(|| Quote::new(default_span))
sourceimpl Quote
impl Quote
Methods for quasi-quotting.
pub fn quote_with<F>(self, quote: F) -> Selfwhere
F: FnOnce(&mut Self),
sourcepub fn push_parsed(&mut self, token: &str)
pub fn push_parsed(&mut self, token: &str)
Parse token
and append it to self
.
sourcepub fn push_group<F>(&mut self, delim: Delimiter, child: F)where
F: FnOnce(&mut Quote),
pub fn push_group<F>(&mut self, delim: Delimiter, child: F)where
F: FnOnce(&mut Quote),
Respan and append TokenStream::Group
sourcepub fn push_tokens<T: ?Sized + ToTokens>(&mut self, node: &T)
pub fn push_tokens<T: ?Sized + ToTokens>(&mut self, node: &T)
Appends node into self
without respanning.
Trait Implementations
sourceimpl From<Quote> for TokenStream
impl From<Quote> for TokenStream
sourceimpl From<Quote> for TokenStream
impl From<Quote> for TokenStream
sourceimpl IntoIterator for Quote
impl IntoIterator for Quote
type IntoIter = <TokenStream as IntoIterator>::IntoIter
type IntoIter = <TokenStream as IntoIterator>::IntoIter
Which kind of iterator are we turning this into?
type Item = <TokenStream as IntoIterator>::Item
type Item = <TokenStream as IntoIterator>::Item
The type of the elements being iterated over.
sourceimpl ToTokens for Quote
impl ToTokens for Quote
sourcefn to_tokens(&self, dst: &mut TokenStream)
fn to_tokens(&self, dst: &mut TokenStream)
sourcefn into_token_stream(self) -> TokenStream
fn into_token_stream(self) -> TokenStream
sourcefn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Auto Trait Implementations
impl !RefUnwindSafe for Quote
impl !Send for Quote
impl !Sync for Quote
impl Unpin for Quote
impl !UnwindSafe for Quote
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
sourcefn span(&self) -> Span
fn span(&self) -> Span
Returns a
Span
covering the complete contents of this syntax tree
node, or Span::call_site()
if this node is empty. Read moresourceimpl<T> ToTokensExt for Twhere
T: ToTokens,
impl<T> ToTokensExt for Twhere
T: ToTokens,
fn dump(&self) -> TokenStream
sourcefn first_last(&self) -> FirstLast
fn first_last(&self) -> FirstLast
Usage:
Quote::new(body.first_last())