pub fn parse_repeated<T: Parse>(input: ParseStream<'_>) -> Result<Vec<T>>
Expand description
Attempts to repeatedly parse input
into the given syntax tree node,
using T
’s default parsing implementation, and continuing until input
is
exhausted.
Note that this function doesn’t perform any error recovery.
§Errors
Forwards any errors from T::parse
.
Examples found in repository?
examples/lox/main.rs (line 528)
515 fn class_declaration(input: ParseStream) -> Result<Self> {
516 let _: kw::class = input.parse()?;
517 let name: Ident = input.parse()?;
518
519 let superclass = if input.peek(Punct!["<"]) {
520 let _: Punct!["<"] = input.parse()?;
521 Some(input.parse()?)
522 } else {
523 None
524 };
525
526 let content;
527 let _: Braces = group!(content in input);
528 let methods = parse_repeated(&content)?;
529
530 Ok(Stmt::Class {
531 name,
532 superclass,
533 superclass_distance: Cell::new(None),
534 methods,
535 })
536 }