Gets the callable's syntax specification.
(&self)
| 608 | |
| 609 | /// Gets the callable's syntax specification. |
| 610 | pub fn syntax(&self) -> String { |
| 611 | fn format_one(cs: &CallableSyntax) -> String { |
| 612 | let mut syntax = cs.describe(); |
| 613 | if syntax.is_empty() { |
| 614 | syntax.push_str("no arguments"); |
| 615 | } |
| 616 | syntax |
| 617 | } |
| 618 | |
| 619 | match self.syntaxes.as_slice() { |
| 620 | [] => panic!("Callables without syntaxes are not allowed at construction time"), |
| 621 | [one] => format_one(one), |
| 622 | many => many |
| 623 | .iter() |
| 624 | .map(|syn| format!("<{}>", syn.describe())) |
| 625 | .collect::<Vec<String>>() |
| 626 | .join(" | "), |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | /// Returns true if `sep` is valid for a function call (only `Long` and `End` are allowed because |
| 631 | /// the parser only produces comma separators for function arguments). |