pub struct Punctuated<T, P> { /* private fields */ }Expand description
A punctuated sequence of syntax tree nodes of type T separated by
punctuation of type P.
Refer to the module documentation for details about punctuated sequences.
Implementations§
Source§impl<T, P> Punctuated<T, P>
impl<T, P> Punctuated<T, P>
Sourcepub fn new() -> Punctuated<T, P>
pub fn new() -> Punctuated<T, P>
Creates an empty punctuated sequence.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Determines whether this punctuated sequence is empty, meaning it contains no syntax tree nodes or punctuation.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of syntax tree nodes in this punctuated sequence.
This is the number of nodes of type T, not counting the punctuation of
type P.
Sourcepub fn first(&self) -> Option<Pair<&T, &P>>
pub fn first(&self) -> Option<Pair<&T, &P>>
Borrows the first punctuated pair in this sequence.
Sourcepub fn last_mut(&mut self) -> Option<Pair<&mut T, &mut P>>
pub fn last_mut(&mut self) -> Option<Pair<&mut T, &mut P>>
Mutably borrows the last punctuated pair in this sequence.
Sourcepub fn iter(&self) -> Iter<'_, T, P> ⓘ
pub fn iter(&self) -> Iter<'_, T, P> ⓘ
Returns an iterator over borrowed syntax tree nodes of type &T.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, T, P> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, T, P> ⓘ
Returns an iterator over mutably borrowed syntax tree nodes of type
&mut T.
Sourcepub fn pairs(&self) -> Pairs<'_, T, P> ⓘ
pub fn pairs(&self) -> Pairs<'_, T, P> ⓘ
Returns an iterator over the contents of this sequence as borrowed punctuated pairs.
Sourcepub fn pairs_mut(&mut self) -> PairsMut<'_, T, P> ⓘ
pub fn pairs_mut(&mut self) -> PairsMut<'_, T, P> ⓘ
Returns an iterator over the contents of this sequence as mutably borrowed punctuated pairs.
Sourcepub fn into_pairs(self) -> IntoPairs<T, P> ⓘ
pub fn into_pairs(self) -> IntoPairs<T, P> ⓘ
Returns an iterator over the contents of this sequence as owned punctuated pairs.
Sourcepub fn push_value(&mut self, value: T)
pub fn push_value(&mut self, value: T)
Appends a syntax tree node onto the end of this punctuated sequence. The sequence must previously have a trailing punctuation.
Use push instead if the punctuated sequence may or may not already
have trailing punctuation.
§Panics
Panics if the sequence does not already have a trailing punctuation when this method is called.
Sourcepub fn push_punct(&mut self, punctuation: P)
pub fn push_punct(&mut self, punctuation: P)
Appends a trailing punctuation onto the end of this punctuated sequence. The sequence must be non-empty and must not already have trailing punctuation.
§Panics
Panics if the sequence is empty or already has a trailing punctuation.
Sourcepub fn pop(&mut self) -> Option<Pair<T, P>>
pub fn pop(&mut self) -> Option<Pair<T, P>>
Removes the last punctuated pair from this sequence, or None if the
sequence is empty.
Sourcepub fn trailing_punct(&self) -> bool
pub fn trailing_punct(&self) -> bool
Determines whether this punctuated sequence ends with a trailing punctuation.
Sourcepub fn empty_or_trailing(&self) -> bool
pub fn empty_or_trailing(&self) -> bool
Returns true if either this Punctuated is empty, or it has a trailing
punctuation.
Equivalent to punctuated.is_empty() || punctuated.trailing_punct().
Source§impl<T, P> Punctuated<T, P>where
P: Default,
impl<T, P> Punctuated<T, P>where
P: Default,
Source§impl<T, P> Punctuated<T, P>
impl<T, P> Punctuated<T, P>
Sourcepub fn parse_separated(input: Cursor<'_>) -> PResult<'_, Self>
pub fn parse_separated(input: Cursor<'_>) -> PResult<'_, Self>
Parse zero or more syntax tree nodes with punctuation in between and no trailing punctuation.
Sourcepub fn parse_separated_nonempty(input: Cursor<'_>) -> PResult<'_, Self>
pub fn parse_separated_nonempty(input: Cursor<'_>) -> PResult<'_, Self>
Parse one or more syntax tree nodes with punctuation in bewteen and no trailing punctuation. allowing trailing punctuation.
Sourcepub fn parse_terminated(input: Cursor<'_>) -> PResult<'_, Self>
pub fn parse_terminated(input: Cursor<'_>) -> PResult<'_, Self>
Parse zero or more syntax tree nodes with punctuation in between and optional trailing punctuation.
Sourcepub fn parse_terminated_nonempty(input: Cursor<'_>) -> PResult<'_, Self>
pub fn parse_terminated_nonempty(input: Cursor<'_>) -> PResult<'_, Self>
Parse one or more syntax tree nodes with punctuation in between and optional trailing punctuation.
Source§impl<T, P> Punctuated<T, P>where
P: Synom,
impl<T, P> Punctuated<T, P>where
P: Synom,
Sourcepub fn parse_separated_with(
input: Cursor<'_>,
parse: fn(Cursor<'_>) -> PResult<'_, T>,
) -> PResult<'_, Self>
pub fn parse_separated_with( input: Cursor<'_>, parse: fn(Cursor<'_>) -> PResult<'_, T>, ) -> PResult<'_, Self>
Parse zero or more syntax tree nodes using the given parser with punctuation in between and no trailing punctuation.
Sourcepub fn parse_separated_nonempty_with(
input: Cursor<'_>,
parse: fn(Cursor<'_>) -> PResult<'_, T>,
) -> PResult<'_, Self>
pub fn parse_separated_nonempty_with( input: Cursor<'_>, parse: fn(Cursor<'_>) -> PResult<'_, T>, ) -> PResult<'_, Self>
Parse one or more syntax tree nodes using the given parser with punctuation in between and no trailing punctuation.
Trait Implementations§
Source§impl<T: Clone, P: Clone> Clone for Punctuated<T, P>
impl<T: Clone, P: Clone> Clone for Punctuated<T, P>
Source§fn clone(&self) -> Punctuated<T, P>
fn clone(&self) -> Punctuated<T, P>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T, P> Default for Punctuated<T, P>
impl<T, P> Default for Punctuated<T, P>
Source§impl<T, P> Extend<Pair<T, P>> for Punctuated<T, P>
impl<T, P> Extend<Pair<T, P>> for Punctuated<T, P>
Source§fn extend<I: IntoIterator<Item = Pair<T, P>>>(&mut self, i: I)
fn extend<I: IntoIterator<Item = Pair<T, P>>>(&mut self, i: I)
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> Extend<T> for Punctuated<T, P>where
P: Default,
impl<T, P> Extend<T> for Punctuated<T, P>where
P: Default,
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, i: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, i: I)
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§impl<T, P> FromIterator<T> for Punctuated<T, P>where
P: Default,
impl<T, P> FromIterator<T> for Punctuated<T, P>where
P: Default,
Source§fn from_iter<I: IntoIterator<Item = T>>(i: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(i: I) -> Self
Source§impl<T, P> Index<usize> for Punctuated<T, P>
impl<T, P> Index<usize> for Punctuated<T, P>
Source§impl<T, P> IndexMut<usize> for Punctuated<T, P>
impl<T, P> IndexMut<usize> for Punctuated<T, P>
Source§impl<'a, T, P> IntoIterator for &'a Punctuated<T, P>
impl<'a, T, P> IntoIterator for &'a Punctuated<T, P>
Source§impl<'a, T, P> IntoIterator for &'a mut Punctuated<T, P>
impl<'a, T, P> IntoIterator for &'a mut Punctuated<T, P>
Source§impl<T, P> IntoIterator for Punctuated<T, P>
impl<T, P> IntoIterator for Punctuated<T, P>
Source§impl<T, P> ToTokens for Punctuated<T, P>
impl<T, P> ToTokens for Punctuated<T, P>
impl<T: Eq, P: Eq> Eq for Punctuated<T, P>
impl<T, P> StructuralPartialEq for Punctuated<T, P>
Auto Trait Implementations§
impl<T, P> Freeze for Punctuated<T, P>
impl<T, P> RefUnwindSafe for Punctuated<T, P>where
T: RefUnwindSafe,
P: RefUnwindSafe,
impl<T, P> Send for Punctuated<T, P>
impl<T, P> Sync for Punctuated<T, P>
impl<T, P> Unpin for Punctuated<T, P>
impl<T, P> UnwindSafe for Punctuated<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> Spanned for Twhere
T: ToTokens,
impl<T> Spanned for Twhere
T: ToTokens,
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.