(p: &mut Parser<'a, Iter>)
| 64 | |
| 65 | impl<'a, T: Parse<'a> + Peek<'a>, const MIN: usize> Parse<'a> for CommaSeparated<'a, T, MIN> { |
| 66 | fn parse<Iter>(p: &mut Parser<'a, Iter>) -> ParserResult<Self> |
| 67 | where |
| 68 | Iter: Iterator<Item = crate::Cursor> + Clone, |
| 69 | { |
| 70 | let mut items = Self::new_in(p.bump()); |
| 71 | if MIN == 0 && !<T>::peek(p, p.peek_n(1)) { |
| 72 | return Ok(items); |
| 73 | } |
| 74 | loop { |
| 75 | let item = p.parse::<T>()?; |
| 76 | if p.peek::<Comma>() { |
| 77 | let checkpoint = p.checkpoint(); |
| 78 | let comma = p.parse::<Comma>()?; |
| 79 | if !<T>::peek(p, p.peek_n(1)) { |
| 80 | p.rewind(checkpoint); |
| 81 | items.items.push((item, None)); |
| 82 | break; |
| 83 | } |
| 84 | items.items.push((item, Some(comma))); |
| 85 | } else { |
| 86 | items.items.push((item, None)); |
| 87 | break; |
| 88 | } |
| 89 | } |
| 90 | if MIN > items.len() { |
| 91 | p.parse::<Comma>()?; |
| 92 | } |
| 93 | Ok(items) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | impl<'a, T: ToCursors, const MIN: usize> ToCursors for CommaSeparated<'a, T, MIN> { |
nothing calls this directly
no test coverage detected