| 46 | } |
| 47 | |
| 48 | pub(crate) fn parse_path<'heap, 'span, 'source, E>( |
| 49 | input: &mut Input<'heap, 'span, 'source>, |
| 50 | ) -> ModalResult<Path<'heap>, E> |
| 51 | where |
| 52 | E: ParserError<Input<'heap, 'span, 'source>> |
| 53 | + AddContext<Input<'heap, 'span, 'source>, StrContext>, |
| 54 | { |
| 55 | let root = opt(ws("::")).map(|value| value.is_some()); |
| 56 | let segments = separated_alloc1(input.state.heap, parse_path_segment, ws("::")); |
| 57 | |
| 58 | let ((rooted, segments), span) = (root, segments) |
| 59 | .with_span() |
| 60 | .context(StrContext::Label("path")) |
| 61 | .parse_next(input)?; |
| 62 | |
| 63 | Ok(Path { |
| 64 | id: NodeId::PLACEHOLDER, |
| 65 | span: input.state.span(span), |
| 66 | rooted, |
| 67 | segments, |
| 68 | }) |
| 69 | } |
| 70 | |
| 71 | #[cfg(test)] |
| 72 | mod tests { |