swc_macros_common::prelude

Enum Element

source
pub enum Element<T, P> {
    Punctuated(T, P),
    End(T),
}
Expand description

A single syntax tree node of type T followed by its trailing punctuation of type P if any.

Refer to the module documentation for details about punctuated sequences.

Variants§

§

Punctuated(T, P)

§

End(T)

Implementations§

source§

impl<T, P> Pair<T, P>

source

pub fn into_value(self) -> T

Extracts the syntax tree node from this punctuated pair, discarding the following punctuation.

source

pub fn value(&self) -> &T

Borrows the syntax tree node from this punctuated pair.

source

pub fn value_mut(&mut self) -> &mut T

Mutably borrows the syntax tree node from this punctuated pair.

source

pub fn punct(&self) -> Option<&P>

Borrows the punctuation from this punctuated pair, unless this pair is the final one and there is no trailing punctuation.

source

pub fn punct_mut(&mut self) -> Option<&mut P>

Mutably borrows the punctuation from this punctuated pair, unless the pair is the final one and there is no trailing punctuation.

§Example
punctuated.insert(0, parse_quote!('lifetime));
if let Some(punct) = punctuated.pairs_mut().next().unwrap().punct_mut() {
    punct.span = span;
}
source

pub fn new(t: T, p: Option<P>) -> Pair<T, P>

Creates a punctuated pair out of a syntax tree node and an optional following punctuation.

source

pub fn into_tuple(self) -> (T, Option<P>)

Produces this punctuated pair as a tuple of syntax tree node and optional following punctuation.

source§

impl<T, P> Pair<&T, &P>

source

pub fn cloned(self) -> Pair<T, P>
where T: Clone, P: Clone,

Trait Implementations§

source§

impl<T, P> Clone for Pair<T, P>
where T: Clone, P: Clone,

source§

fn clone(&self) -> Pair<T, P>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T, P> Extend<Pair<T, P>> for Punctuated<T, P>
where P: Default,

source§

fn extend<I>(&mut self, i: I)
where I: IntoIterator<Item = Pair<T, P>>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T, P> FromIterator<Pair<T, P>> for Punctuated<T, P>

source§

fn from_iter<I>(i: I) -> Punctuated<T, P>
where I: IntoIterator<Item = Pair<T, P>>,

Creates a value from an iterator. Read more
source§

impl<T, P> PairExt<T, P> for Pair<T, P>

source§

fn map_item<F, NewItem>(self, op: F) -> Pair<NewItem, P>
where F: FnOnce(T) -> NewItem,

source§

impl<T, P> ToTokens for Pair<T, P>
where T: ToTokens, P: ToTokens,

source§

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

Write self to the given TokenStream. Read more
source§

fn to_token_stream(&self) -> TokenStream

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

fn into_token_stream(self) -> TokenStream
where Self: Sized,

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

impl<T, P> Copy for Pair<T, P>
where T: Copy, P: Copy,

Auto Trait Implementations§

§

impl<T, P> Freeze for Pair<T, P>
where T: Freeze, P: Freeze,

§

impl<T, P> RefUnwindSafe for Pair<T, P>

§

impl<T, P> Send for Pair<T, P>
where T: Send, P: Send,

§

impl<T, P> Sync for Pair<T, P>
where T: Sync, P: Sync,

§

impl<T, P> Unpin for Pair<T, P>
where T: Unpin, P: Unpin,

§

impl<T, P> UnwindSafe for Pair<T, P>
where T: UnwindSafe, P: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.