Struct pmutil::spanned_quote::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) -> Nodewhere 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) -> Selfwhere 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

§

type IntoIter = <TokenStream as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
§

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 !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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToTokensExt for Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.