Struct syn::punctuated::Punctuated [−][src]
pub struct Punctuated<T, P> { /* fields omitted */ }
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
Determines whether this punctuated sequence is empty, meaning it contains no syntax tree nodes or punctuation.
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
.
Mutably borrows the first element in this sequence.
Returns an iterator over borrowed syntax tree nodes of type &T
.
Returns an iterator over mutably borrowed syntax tree nodes of type
&mut T
.
Returns an iterator over the contents of this sequence as borrowed punctuated pairs.
Returns an iterator over the contents of this sequence as mutably borrowed punctuated pairs.
Returns an iterator over the contents of this sequence as owned punctuated pairs.
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.
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.
Removes the last punctuated pair from this sequence, or None
if the
sequence is empty.
Determines whether this punctuated sequence ends with a trailing punctuation.
Returns true if either this Punctuated
is empty, or it has a trailing
punctuation.
Equivalent to punctuated.is_empty() || punctuated.trailing_punct()
.
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
.
Inserts an element at position index
.
Panics
Panics if index
is greater than the number of elements previously in
this punctuated sequence.
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,
pub fn parse_terminated_with(
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,
pub fn parse_separated_nonempty(input: ParseStream<'_>) -> Result<Self> where
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,
pub fn parse_separated_nonempty_with(
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
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
Auto Trait Implementations
impl<T, P> RefUnwindSafe for Punctuated<T, P> where
P: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, P> Send for Punctuated<T, P> where
P: Send,
T: Send,
impl<T, P> Sync for Punctuated<T, P> where
P: Sync,
T: Sync,
impl<T, P> Unpin for Punctuated<T, P> where
P: Unpin,
T: Unpin,
impl<T, P> UnwindSafe for Punctuated<T, P> where
P: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more