css_parse/traits/lists/
prelude_list.rs

1use crate::{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(p: &mut Parser<'a>) -> Result<Vec<'a, Self::PreludeItem>> {
9		let mut items = Vec::new_in(p.bump());
10		loop {
11			items.push(p.parse::<Self::PreludeItem>()?);
12			if p.peek_next() == Self::STOP_TOKENS {
13				return Ok(items);
14			}
15		}
16	}
17}