Finds the syntax definition that matches the given argument count. Returns an error if no syntax matches, and panics if multiple syntaxes match (which would indicate an ambiguous callable definition).
(&self, nargs: usize)
| 671 | /// Returns an error if no syntax matches, and panics if multiple syntaxes match (which would |
| 672 | /// indicate an ambiguous callable definition). |
| 673 | pub(crate) fn find_syntax(&self, nargs: usize) -> Option<&CallableSyntax> { |
| 674 | let mut matches = self.syntaxes.iter().filter(|s| s.expected_nargs().contains(&nargs)); |
| 675 | let syntax = matches.next(); |
| 676 | match syntax { |
| 677 | Some(syntax) => { |
| 678 | debug_assert!(matches.next().is_none(), "Ambiguous syntax definitions"); |
| 679 | if cfg!(debug_assertions) { |
| 680 | self.debug_assert_function_seps(syntax); |
| 681 | } |
| 682 | Some(syntax) |
| 683 | } |
| 684 | None => None, |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | /// Gets the callable's category as a collection of lines. The first line is the title of the |
| 689 | /// category, and any extra lines are additional information for it. |
no test coverage detected