Struct Punctuated
struct Punctuated<T, P> { ... }
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
impl<T, P> Punctuated<T, P>
const fn new() -> SelfCreates an empty punctuated sequence.
fn is_empty(self: &Self) -> boolDetermines whether this punctuated sequence is empty, meaning it contains no syntax tree nodes or punctuation.
fn len(self: &Self) -> usizeReturns the number of syntax tree nodes in this punctuated sequence.
This is the number of nodes of type
T, not counting the punctuation of typeP.fn first(self: &Self) -> Option<&T>Borrows the first element in this sequence.
fn first_mut(self: &mut Self) -> Option<&mut T>Mutably borrows the first element in this sequence.
fn last(self: &Self) -> Option<&T>Borrows the last element in this sequence.
fn last_mut(self: &mut Self) -> Option<&mut T>Mutably borrows the last element in this sequence.
fn get(self: &Self, index: usize) -> Option<&T>Borrows the element at the given index.
fn get_mut(self: &mut Self, index: usize) -> Option<&mut T>Mutably borrows the element at the given index.
fn iter(self: &Self) -> Iter<'_, T>Returns an iterator over borrowed syntax tree nodes of type
&T.fn iter_mut(self: &mut Self) -> IterMut<'_, T>Returns an iterator over mutably borrowed syntax tree nodes of type
&mut T.fn pairs(self: &Self) -> Pairs<'_, T, P>Returns an iterator over the contents of this sequence as borrowed punctuated pairs.
fn pairs_mut(self: &mut Self) -> PairsMut<'_, T, P>Returns an iterator over the contents of this sequence as mutably borrowed punctuated pairs.
fn into_pairs(self: Self) -> IntoPairs<T, P>Returns an iterator over the contents of this sequence as owned punctuated pairs.
fn push_value(self: &mut Self, value: T)Appends a syntax tree node onto the end of this punctuated sequence. The sequence must already have a trailing punctuation, or be empty.
Use
pushinstead if the punctuated sequence may or may not already have trailing punctuation.Panics
Panics if the sequence is nonempty and does not already have a trailing punctuation.
fn push_punct(self: &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.
fn pop(self: &mut Self) -> Option<Pair<T, P>>Removes the last punctuated pair from this sequence, or
Noneif the sequence is empty.fn pop_punct(self: &mut Self) -> Option<P>Removes the trailing punctuation from this punctuated sequence, or
Noneif there isn't any.fn trailing_punct(self: &Self) -> boolDetermines whether this punctuated sequence ends with a trailing punctuation.
fn empty_or_trailing(self: &Self) -> boolReturns true if either this
Punctuatedis empty, or it has a trailing punctuation.Equivalent to
punctuated.is_empty() || punctuated.trailing_punct().fn push(self: &mut Self, value: T) where P: DefaultAppends a syntax tree node onto the end of this punctuated sequence.
If there is not a trailing punctuation in this sequence when this method is called, the default value of punctuation type
Pis inserted before the given value of typeT.fn insert(self: &mut Self, index: usize, value: T) where P: DefaultInserts an element at position
index.Panics
Panics if
indexis greater than the number of elements previously in this punctuated sequence.fn clear(self: &mut Self)Clears the sequence of all values and punctuation, making it empty.
fn parse_terminated(input: ParseStream<'_>) -> Result<Self> where T: Parse, P: ParseParses zero or more occurrences of
Tseparated by punctuation of typeP, with optional trailing punctuation.Parsing continues until the end of this parse stream. The entire content of this parse stream must consist of
TandP.fn parse_terminated_with<'a>(input: ParseStream<'a>, parser: fn(_: ParseStream<'a>) -> Result<T>) -> Result<Self> where P: ParseParses zero or more occurrences of
Tusing the given parse function, separated by punctuation of typeP, with optional trailing punctuation.Like
parse_terminated, the entire content of this stream is expected to be parsed.fn parse_separated_nonempty(input: ParseStream<'_>) -> Result<Self> where T: Parse, P: Token + ParseParses one or more occurrences of
Tseparated by punctuation of typeP, not accepting trailing punctuation.Parsing continues as long as punctuation
Pis present at the head of the stream. This method returns upon parsing aTand observing that it is not followed by aP, even if there are remaining tokens in the stream.fn parse_separated_nonempty_with<'a>(input: ParseStream<'a>, parser: fn(_: ParseStream<'a>) -> Result<T>) -> Result<Self> where P: Token + ParseParses one or more occurrences of
Tusing the given parse function, separated by punctuation of typeP, not accepting trailing punctuation.Like
parse_separated_nonempty, may complete early without parsing the entire content of this stream.
impl<T> Any for Punctuated<T, P>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Punctuated<T, P>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Punctuated<T, P>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Punctuated<T, P>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Punctuated<T, P>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Spanned for Punctuated<T, P>
fn span(self: &Self) -> Span
impl<T> ToOwned for Punctuated<T, P>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, P> Clone for Punctuated<T, P>
fn clone(self: &Self) -> Selffn clone_from(self: &mut Self, other: &Self)
impl<T, P> Default for Punctuated<T, P>
fn default() -> Self
impl<T, P> Eq for Punctuated<T, P>
impl<T, P> Extend for Punctuated<T, P>
fn extend<I: IntoIterator<Item = T>>(self: &mut Self, i: I)
impl<T, P> Extend for Punctuated<T, P>
fn extend<I: IntoIterator<Item = Pair<T, P>>>(self: &mut Self, i: I)
impl<T, P> Freeze for Punctuated<T, P>
impl<T, P> FromIterator for Punctuated<T, P>
fn from_iter<I: IntoIterator<Item = Pair<T, P>>>(i: I) -> Self
impl<T, P> FromIterator for Punctuated<T, P>
fn from_iter<I: IntoIterator<Item = T>>(i: I) -> Self
impl<T, P> Hash for Punctuated<T, P>
fn hash<H: Hasher>(self: &Self, state: &mut H)
impl<T, P> Index for Punctuated<T, P>
fn index(self: &Self, index: usize) -> &<Self as >::Output
impl<T, P> IndexMut for Punctuated<T, P>
fn index_mut(self: &mut Self, index: usize) -> &mut <Self as >::Output
impl<T, P> IntoIterator for Punctuated<T, P>
fn into_iter(self: Self) -> <Self as >::IntoIter
impl<T, P> PartialEq for Punctuated<T, P>
fn eq(self: &Self, other: &Self) -> bool
impl<T, P> RefUnwindSafe for Punctuated<T, P>
impl<T, P> Send for Punctuated<T, P>
impl<T, P> Sync for Punctuated<T, P>
impl<T, P> ToTokens for crate::punctuated::Punctuated<T, P>
fn to_tokens(self: &Self, tokens: &mut TokenStream)
impl<T, P> Unpin for Punctuated<T, P>
impl<T, P> UnwindSafe for Punctuated<T, P>
impl<T, U> Into for Punctuated<T, P>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Punctuated<T, P>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Punctuated<T, P>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T: Debug, P: Debug> Debug for Punctuated<T, P>
fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result