Enum Pair

enum Pair<T, P>

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

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

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

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

fn into_value(self: Self) -> T

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

fn value(self: &Self) -> &T

Borrows the syntax tree node from this punctuated pair.

fn value_mut(self: &mut Self) -> &mut T

Mutably borrows the syntax tree node from this punctuated pair.

fn punct(self: &Self) -> Option<&P>

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

fn punct_mut(self: &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

# use proc_macro2::Span;
# use syn::punctuated::Punctuated;
# use syn::{parse_quote, Token, TypeParamBound};
#
# let mut punctuated = Punctuated::<TypeParamBound, Token![+]>::new();
# let span = Span::call_site();
#
punctuated.insert(0, parse_quote!('lifetime));
if let Some(punct) = punctuated.pairs_mut().next().unwrap().punct_mut() {
    punct.span = span;
}
fn new(t: T, p: Option<P>) -> Self

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

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

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

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

fn type_id(self: &Self) -> TypeId

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

fn borrow(self: &Self) -> &T

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

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

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

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

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

fn from(t: T) -> T

Returns the argument unchanged.

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

fn span(self: &Self) -> Span

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

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

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

fn clone(self: &Self) -> Self

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

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

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

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

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

impl<T, P> ToTokens for crate::punctuated::Pair<T, P>

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

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

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

impl<T, U> Into for Pair<T, P>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for Pair<T, P>

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

impl<T, U> TryInto for Pair<T, P>

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