[−][src]Struct syn::punctuated::Punctuated
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>
[src]
pub fn new() -> Punctuated<T, P>
[src]
Creates an empty punctuated sequence.
pub fn is_empty(&self) -> bool
[src]
Determines whether this punctuated sequence is empty, meaning it contains no syntax tree nodes or punctuation.
pub fn len(&self) -> usize
[src]
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
.
pub fn first(&self) -> Option<&T>
[src]
Borrows the first element in this sequence.
pub fn first_mut(&mut self) -> Option<&mut T>
[src]
Mutably borrows the first element in this sequence.
pub fn last(&self) -> Option<&T>
[src]
Borrows the last element in this sequence.
pub fn last_mut(&mut self) -> Option<&mut T>
[src]
Mutably borrows the last element in this sequence.
pub fn iter(&self) -> Iter<'_, T>ⓘ
[src]
Returns an iterator over borrowed syntax tree nodes of type &T
.
pub fn iter_mut(&mut self) -> IterMut<'_, T>ⓘ
[src]
Returns an iterator over mutably borrowed syntax tree nodes of type
&mut T
.
pub fn pairs(&self) -> Pairs<'_, T, P>ⓘ
[src]
Returns an iterator over the contents of this sequence as borrowed punctuated pairs.
pub fn pairs_mut(&mut self) -> PairsMut<'_, T, P>ⓘ
[src]
Returns an iterator over the contents of this sequence as mutably borrowed punctuated pairs.
pub fn into_pairs(self) -> IntoPairs<T, P>ⓘ
[src]
Returns an iterator over the contents of this sequence as owned punctuated pairs.
pub fn push_value(&mut self, value: T)
[src]
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.
pub fn push_punct(&mut self, punctuation: P)
[src]
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.
pub fn pop(&mut self) -> Option<Pair<T, P>>
[src]
Removes the last punctuated pair from this sequence, or None
if the
sequence is empty.
pub fn trailing_punct(&self) -> bool
[src]
Determines whether this punctuated sequence ends with a trailing punctuation.
pub fn empty_or_trailing(&self) -> bool
[src]
Returns true if either this Punctuated
is empty, or it has a trailing
punctuation.
Equivalent to punctuated.is_empty() || punctuated.trailing_punct()
.
pub fn push(&mut self, value: T) where
P: Default,
[src]
P: Default,
Appends 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 P
is inserted before
the given value of type T
.
pub fn insert(&mut self, index: usize, value: T) where
P: Default,
[src]
P: Default,
Inserts an element at position index
.
Panics
Panics if index
is greater than the number of elements previously in
this punctuated sequence.
pub fn clear(&mut self)
[src]
Clears the sequence of all values and punctuation, making it empty.
pub fn parse_terminated(input: ParseStream<'_>) -> Result<Self> where
T: Parse,
P: Parse,
[src]
T: Parse,
P: Parse,
Parses zero or more occurrences of T
separated by punctuation of type
P
, with optional trailing punctuation.
Parsing continues until the end of this parse stream. The entire content
of this parse stream must consist of T
and P
.
This function is available only if Syn is built with the "parsing"
feature.
pub fn parse_terminated_with(
input: ParseStream<'_>,
parser: fn(_: ParseStream<'_>) -> Result<T>
) -> Result<Self> where
P: Parse,
[src]
input: ParseStream<'_>,
parser: fn(_: ParseStream<'_>) -> Result<T>
) -> Result<Self> where
P: Parse,
Parses zero or more occurrences of T
using the given parse function,
separated by punctuation of type P
, with optional trailing
punctuation.
Like parse_terminated
, the entire content of this stream is expected
to be parsed.
This function is available only if Syn is built with the "parsing"
feature.
pub fn parse_separated_nonempty(input: ParseStream<'_>) -> Result<Self> where
T: Parse,
P: Token + Parse,
[src]
T: Parse,
P: Token + Parse,
Parses one or more occurrences of T
separated by punctuation of type
P
, not accepting trailing punctuation.
Parsing continues as long as punctuation P
is present at the head of
the stream. This method returns upon parsing a T
and observing that it
is not followed by a P
, even if there are remaining tokens in the
stream.
This function is available only if Syn is built with the "parsing"
feature.
pub fn parse_separated_nonempty_with(
input: ParseStream<'_>,
parser: fn(_: ParseStream<'_>) -> Result<T>
) -> Result<Self> where
P: Token + Parse,
[src]
input: ParseStream<'_>,
parser: fn(_: ParseStream<'_>) -> Result<T>
) -> Result<Self> where
P: Token + Parse,
Parses one or more occurrences of T
using the given parse function,
separated by punctuation of type P
, not accepting trailing
punctuation.
Like parse_separated_nonempty
, may complete early without parsing
the entire content of this stream.
This function is available only if Syn is built with the "parsing"
feature.
Trait Implementations
impl<T, P> Clone for Punctuated<T, P> where
T: Clone,
P: Clone,
[src]
T: Clone,
P: Clone,
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug, P: Debug> Debug for Punctuated<T, P>
[src]
impl<T, P> Default for Punctuated<T, P>
[src]
impl<T, P> Eq for Punctuated<T, P> where
T: Eq,
P: Eq,
[src]
T: Eq,
P: Eq,
impl<T, P> Extend<Pair<T, P>> for Punctuated<T, P>
[src]
pub fn extend<I: IntoIterator<Item = Pair<T, P>>>(&mut self, i: I)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<T, P> Extend<T> for Punctuated<T, P> where
P: Default,
[src]
P: Default,
pub fn extend<I: IntoIterator<Item = T>>(&mut self, i: I)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<T, P> FromIterator<Pair<T, P>> for Punctuated<T, P>
[src]
pub fn from_iter<I: IntoIterator<Item = Pair<T, P>>>(i: I) -> Self
[src]
impl<T, P> FromIterator<T> for Punctuated<T, P> where
P: Default,
[src]
P: Default,
pub fn from_iter<I: IntoIterator<Item = T>>(i: I) -> Self
[src]
impl<T, P> Hash for Punctuated<T, P> where
T: Hash,
P: Hash,
[src]
T: Hash,
P: Hash,
pub fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T, P> Index<usize> for Punctuated<T, P>
[src]
type Output = T
The returned type after indexing.
pub fn index(&self, index: usize) -> &Self::Output
[src]
impl<T, P> IndexMut<usize> for Punctuated<T, P>
[src]
impl<T, P> IntoIterator for Punctuated<T, P>
[src]
type Item = T
The type of the elements being iterated over.
type IntoIter = IntoIter<T>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, T, P> IntoIterator for &'a Punctuated<T, P>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, T, P> IntoIterator for &'a mut Punctuated<T, P>
[src]
type Item = &'a mut T
The type of the elements being iterated over.
type IntoIter = IterMut<'a, T>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> Self::IntoIter
[src]
impl<T, P> PartialEq<Punctuated<T, P>> for Punctuated<T, P> where
T: PartialEq,
P: PartialEq,
[src]
T: PartialEq,
P: PartialEq,
pub fn eq(&self, other: &Self) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T, P> ToTokens for Punctuated<T, P> where
T: ToTokens,
P: ToTokens,
[src]
T: ToTokens,
P: ToTokens,
pub fn to_tokens(&self, tokens: &mut TokenStream)
[src]
pub fn to_token_stream(&self) -> TokenStream
[src]
pub fn into_token_stream(self) -> TokenStream
[src]
Auto Trait Implementations
impl<T, P> RefUnwindSafe for Punctuated<T, P> where
P: RefUnwindSafe,
T: RefUnwindSafe,
P: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, P> Send for Punctuated<T, P> where
P: Send,
T: Send,
P: Send,
T: Send,
impl<T, P> Sync for Punctuated<T, P> where
P: Sync,
T: Sync,
P: Sync,
T: Sync,
impl<T, P> Unpin for Punctuated<T, P> where
P: Unpin,
T: Unpin,
P: Unpin,
T: Unpin,
impl<T, P> UnwindSafe for Punctuated<T, P> where
P: UnwindSafe,
T: UnwindSafe,
P: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Spanned for T where
T: Spanned + ?Sized,
[src]
T: Spanned + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,