Struct flexi_parse::punctuated::Punctuated
source · pub struct Punctuated<T, P: Punct> { /* private fields */ }Expand description
A series of pairs of T and P, optionally followed by another T.
Implementations§
source§impl<T, P: Punct> Punctuated<T, P>
impl<T, P: Punct> Punctuated<T, P>
sourcepub fn parse_separated(input: ParseStream<'_>) -> Result<Self>where
T: Parse,
pub fn parse_separated(input: ParseStream<'_>) -> Result<Self>where
T: Parse,
Parses instances of T separated by instances of P, with no trailing
punctuation.
Note that this will stop as soon as it encounters a token that doesn’t fit this pattern.
Errors
Forwards any errors from T::parse.
sourcepub fn parse_separated_with<F: FnMut(ParseStream<'_>) -> Result<T>>(
input: ParseStream<'_>,
f: F
) -> Result<Self>
pub fn parse_separated_with<F: FnMut(ParseStream<'_>) -> Result<T>>( input: ParseStream<'_>, f: F ) -> Result<Self>
Parses instances of T using f, separated by instances of P, with
no trailing punctuation.
Note that this will stop as soon as it encounters a token that doesn’t fit this pattern.
Errors
Forwards any errors from f.
sourcepub fn parse_separated_trailing(input: ParseStream<'_>) -> Result<Self>where
T: Parse,
pub fn parse_separated_trailing(input: ParseStream<'_>) -> Result<Self>where
T: Parse,
Parses instances of T separated by instances of P, with optional
trailing punctuation.
Note that this will stop as soon as it encounters a token that doesn’t fit this pattern.
Errors
Forwards any errors from T::parse.
Examples found in repository?
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
fn finish_call(input: ParseStream<'_>, callee: Expr) -> Result<Self> {
let content;
let paren: Parentheses = group!(content in input);
let arguments: Punctuated<Expr, Punct![","]> =
Punctuated::parse_separated_trailing(&content)?;
let arguments: Vec<_> = arguments.into_iter().collect();
if arguments.len() >= 255 {
input.add_error(input.new_error(
"Can't have more than 254 arguments".to_string(),
paren.0.clone(),
error_codes::TOO_MANY_ARGS,
));
}
Ok(Expr::Call {
callee: Box::new(callee),
paren,
arguments,
})
}sourcepub fn parse_separated_trailing_with<F: FnMut(ParseStream<'_>) -> Result<T>>(
input: ParseStream<'_>,
f: F
) -> Result<Self>
pub fn parse_separated_trailing_with<F: FnMut(ParseStream<'_>) -> Result<T>>( input: ParseStream<'_>, f: F ) -> Result<Self>
Parses instances of T using f, separated by instances of P, with
optional trailing punctuation.
Note that this will stop as soon as it encounters a token that doesn’t fit this pattern.
Errors
Forwards any errors from f.
sourcepub fn parse_terminated(input: ParseStream<'_>) -> Result<Self>where
T: Parse,
pub fn parse_terminated(input: ParseStream<'_>) -> Result<Self>where
T: Parse,
Parses instances of T separated by instances of P, with trailing
punctuation.
Note that this function attempts to consume the entire stream.
Errors
Forwards any errors from T::parse.
sourcepub fn parse_terminated_with<F: FnMut(ParseStream<'_>) -> Result<T>>(
input: ParseStream<'_>,
f: F
) -> Result<Self>
pub fn parse_terminated_with<F: FnMut(ParseStream<'_>) -> Result<T>>( input: ParseStream<'_>, f: F ) -> Result<Self>
trailing punctuation.
Note that this function attempts to consume the entire stream.
Errors
Forwards any errors from f.
sourcepub fn iter_mut(&mut self) -> IterMut<'_, T, P> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, T, P> ⓘ
Returns an iterator that allows modifying each value.
sourcepub fn pairs(&self) -> Pairs<'_, T, P> ⓘ
pub fn pairs(&self) -> Pairs<'_, T, P> ⓘ
Returns an iterator over the pairs of values and punctuation in this struct.
sourcepub fn pairs_mut(&mut self) -> PairsMut<'_, T, P> ⓘ
pub fn pairs_mut(&mut self) -> PairsMut<'_, T, P> ⓘ
Returns an iterator that allows modifying each pair.
sourcepub fn into_pairs(self) -> IntoPairs<T, P> ⓘ
pub fn into_pairs(self) -> IntoPairs<T, P> ⓘ
Returns a consuming iterator over the pairs in this struct.
Trait Implementations§
source§impl<T: Clone, P: Clone + Punct> Clone for Punctuated<T, P>
impl<T: Clone, P: Clone + Punct> 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 more