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§
Implementations§
Source§impl<T, P> Pair<T, P>
impl<T, P> Pair<T, P>
Sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Extracts the syntax tree node from this punctuated pair, discarding the following punctuation.
Sourcepub fn value_mut(&mut self) -> &mut T
pub fn value_mut(&mut self) -> &mut T
Mutably borrows the syntax tree node from this punctuated pair.
Sourcepub fn punct(&self) -> Option<&P>
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.
Sourcepub fn punct_mut(&mut self) -> Option<&mut P>
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;
}
Sourcepub fn new(t: T, p: Option<P>) -> Pair<T, P>
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.
Sourcepub fn into_tuple(self) -> (T, Option<P>)
pub fn into_tuple(self) -> (T, Option<P>)
Produces this punctuated pair as a tuple of syntax tree node and optional following punctuation.
Trait Implementations§
Source§impl<T, P> Extend<Pair<T, P>> for Punctuated<T, P>where
P: Default,
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>>,
fn extend<I>(&mut self, i: I)where
I: IntoIterator<Item = Pair<T, P>>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<T, P> FromIterator<Pair<T, P>> for Punctuated<T, P>
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>>,
fn from_iter<I>(i: I) -> Punctuated<T, P>where
I: IntoIterator<Item = Pair<T, P>>,
Source§impl<T, P> ToTokens for Pair<T, P>
impl<T, P> ToTokens for Pair<T, P>
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
impl<T, P> Copy for Pair<T, P>
Auto Trait Implementations§
impl<T, P> Freeze for Pair<T, P>
impl<T, P> RefUnwindSafe for Pair<T, P>where
T: RefUnwindSafe,
P: RefUnwindSafe,
impl<T, P> Send for Pair<T, P>
impl<T, P> Sync for Pair<T, P>
impl<T, P> Unpin for Pair<T, P>
impl<T, P> UnwindSafe for Pair<T, P>where
T: UnwindSafe,
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> QuickToOwned for Twhere
T: ToOwned,
impl<T> QuickToOwned for Twhere
T: ToOwned,
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Span
covering the complete contents of this syntax tree
node, or Span::call_site()
if this node is empty.