Return the next capturing index. Each subsequent call increments the internal index. The span given should correspond to the location of the opening parenthesis. If the capture limit is exceeded, then an error is returned.
(&self, span: Span)
| 425 | /// |
| 426 | /// If the capture limit is exceeded, then an error is returned. |
| 427 | fn next_capture_index(&self, span: Span) -> Result<u32> { |
| 428 | let current = self.parser().capture_index.get(); |
| 429 | let i = current.checked_add(1).ok_or_else(|| { |
| 430 | self.error(span, ast::ErrorKind::CaptureLimitExceeded) |
| 431 | })?; |
| 432 | self.parser().capture_index.set(i); |
| 433 | Ok(i) |
| 434 | } |
| 435 | |
| 436 | /// Adds the given capture name to this parser. If this capture name has |
| 437 | /// already been used, then an error is returned. |
no test coverage detected