Adds the given capture name to this parser. If this capture name has already been used, then an error is returned.
(&self, cap: &ast::CaptureName)
| 436 | /// Adds the given capture name to this parser. If this capture name has |
| 437 | /// already been used, then an error is returned. |
| 438 | fn add_capture_name(&self, cap: &ast::CaptureName) -> Result<()> { |
| 439 | let mut names = self.parser().capture_names.borrow_mut(); |
| 440 | match names.binary_search_by_key( |
| 441 | &cap.name.as_str(), |
| 442 | |c| c.name.as_str(), |
| 443 | ) { |
| 444 | Err(i) => { |
| 445 | names.insert(i, cap.clone()); |
| 446 | Ok(()) |
| 447 | } |
| 448 | Ok(i) => { |
| 449 | Err(self.error(cap.span, ast::ErrorKind::GroupNameDuplicate { |
| 450 | original: names[i].span, |
| 451 | })) |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | /// Return whether the parser should ignore whitespace or not. |
| 457 | fn ignore_whitespace(&self) -> bool { |