pmutil::spanned_quote

Struct Quote

Source
pub struct Quote { /* private fields */ }
Expand description

Buffer for quasi quotting.

Implementations§

Source§

impl Quote

Source

pub fn new<S: Respan + 'static>(span: S) -> Self

Source

pub fn new_call_site() -> Self

Shorthand for

Quote::new(Span::call_site())
Source

pub fn from_tokens(tokens: &dyn ToTokens) -> Self

Shorthand for

Quote::new(tokens.first_last())
Source

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))
Source§

impl Quote

Source

pub fn parse<Node>(self) -> Node
where Node: Parse,

Parse tokens as Node. Panics if parsing failed.

Source§

impl Quote

Methods for quasi-quotting.

Source

pub fn quote_with<F>(self, quote: F) -> Self
where F: FnOnce(&mut Self),

Source

pub fn push_parsed(&mut self, token: &str)

Parse token and append it to self.

Source

pub fn push_tt(&mut self, tt: TokenTree)

Append tt to self.

Source

pub fn push_sym(&mut self, term: &str)

Respan symbol and append it to self.

Source

pub fn push_group<F>(&mut self, delim: Delimiter, child: F)
where F: FnOnce(&mut Quote),

Respan and append TokenStream::Group

Source

pub fn push_tokens<T: ?Sized + ToTokens>(&mut self, node: &T)

Appends node into self without respanning.

Trait Implementations§

Source§

impl From<Quote> for TokenStream

Source§

fn from(quote: Quote) -> Self

Converts to this type from the input type.
Source§

impl From<Quote> for TokenStream

Source§

fn from(quote: Quote) -> Self

Converts to this type from the input type.
Source§

impl IntoIterator for Quote

Source§

type IntoIter = <TokenStream as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

type Item = <TokenStream as IntoIterator>::Item

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl ToTokens for Quote

Source§

fn to_tokens(&self, dst: &mut TokenStream)

Write self to the given TokenStream. Read more
Source§

fn into_token_stream(self) -> TokenStream

Convert self directly into a TokenStream object. Read more
Source§

fn to_token_stream(&self) -> TokenStream

Convert self directly into a TokenStream object. Read more

Auto Trait Implementations§

§

impl Freeze for Quote

§

impl !RefUnwindSafe for Quote

§

impl !Send for Quote

§

impl !Sync for Quote

§

impl Unpin for Quote

§

impl !UnwindSafe for Quote

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Spanned for T
where T: Spanned + ?Sized,

Source§

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.
Source§

impl<T> ToTokensExt for T
where T: ToTokens,

Source§

fn dump(&self) -> TokenStream

Source§

fn first_last(&self) -> FirstLast

Usage: Quote::new(body.first_last())
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.