MCPcopy Create free account
hub / github.com/csskit/csskit / parse

Method parse

crates/css_parse/src/syntax/either.rs:23–35  ·  view source on GitHub ↗
(p: &mut crate::Parser<'a, I>)

Source from the content-addressed store, hash-verified

21
22impl<'a, Left: Parse<'a> + Peek<'a>, Right: Parse<'a>> Parse<'a> for Either<Left, Right> {
23 fn parse<I>(p: &mut crate::Parser<'a, I>) -> crate::Result<Self>
24 where
25 I: Iterator<Item = Cursor> + Clone,
26 {
27 let c = p.peek_n(1);
28 if Left::peek(p, c)
29 && let Ok(res) = Left::parse(p)
30 {
31 Ok(Either::Left(res))
32 } else {
33 Right::parse(p).map(Either::Right)
34 }
35 }
36}
37
38impl<Left: ToCursors, Right: ToCursors> ToCursors for Either<Left, Right> {

Callers

nothing calls this directly

Calls 2

peek_nMethod · 0.80
parseFunction · 0.50

Tested by

no test coverage detected