lewp_css/parsers/
parse.rs1use {
5 super::{
6 separators::{Separated, Separator},
7 ParserContext,
8 },
9 crate::CustomParseError,
10 cssparser::{ParseError, Parser, UnicodeRange},
11};
12
13pub(crate) trait Parse: Sized {
14 fn parse<'i, 't>(
18 context: &ParserContext,
19 input: &mut Parser<'i, 't>,
20 ) -> Result<Self, ParseError<'i, CustomParseError<'i>>>;
21}
22
23impl<T> Parse for Vec<T>
24where
25 T: Parse + Separated,
26 <T as Separated>::Delimiter: Separator,
27{
28 fn parse<'i, 't>(
29 context: &ParserContext,
30 input: &mut Parser<'i, 't>,
31 ) -> Result<Self, ParseError<'i, CustomParseError<'i>>> {
32 <T as Separated>::Delimiter::parse(input, |i| T::parse(context, i))
33 }
34}
35
36impl Parse for ::cssparser::UnicodeRange {
37 fn parse<'i, 't>(
38 _context: &ParserContext,
39 input: &mut Parser<'i, 't>,
40 ) -> Result<Self, ParseError<'i, CustomParseError<'i>>> {
41 UnicodeRange::parse(input).map_err(|e| e.into())
42 }
43}