css_parse/traits/lists/
prelude_list.rs

1use crate::{Cursor, KindSet, Parse, Parser, Result};
2use bumpalo::collections::Vec;
3
4pub trait PreludeList<'a>: Sized + Parse<'a> {
5	type PreludeItem: Parse<'a>;
6	const STOP_TOKENS: KindSet = KindSet::LEFT_CURLY_OR_SEMICOLON;
7
8	fn parse_prelude_list<I>(p: &mut Parser<'a, I>) -> Result<Vec<'a, Self::PreludeItem>>
9	where
10		I: Iterator<Item = Cursor> + Clone,
11	{
12		let mut items = Vec::new_in(p.bump());
13		loop {
14			items.push(p.parse::<Self::PreludeItem>()?);
15			if p.peek_n(1) == Self::STOP_TOKENS {
16				return Ok(items);
17			}
18		}
19	}
20}