(p: &mut crate::Parser<'a, I>)
| 21 | |
| 22 | impl<'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 | |
| 38 | impl<Left: ToCursors, Right: ToCursors> ToCursors for Either<Left, Right> { |