syn::punctuated

Enum Pair

Source
pub enum Pair<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>) -> Self

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) -> Self

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: IntoIterator<Item = Pair<T, P>>>(&mut self, i: I)

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: IntoIterator<Item = Pair<T, P>>>(i: I) -> Self

Creates a value from an iterator. Read more
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.