diff options
author | Nadrieril | 2019-09-10 16:29:48 +0200 |
---|---|---|
committer | Nadrieril | 2019-09-10 16:38:28 +0200 |
commit | 26f54b10314f90dc5457cd0760af7f109be78e5f (patch) | |
tree | 892fd7e0be529e9a5c67f1893b854fb3e2a7172b /pest_consume/src/lib.rs | |
parent | 65fd9a895ba3093f9b5d9d02fb8bd18a9be61808 (diff) |
Use an enum instead of strings for rule aliasing
Diffstat (limited to 'pest_consume/src/lib.rs')
-rw-r--r-- | pest_consume/src/lib.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/pest_consume/src/lib.rs b/pest_consume/src/lib.rs index 439effb..62361f2 100644 --- a/pest_consume/src/lib.rs +++ b/pest_consume/src/lib.rs @@ -78,7 +78,7 @@ impl<'i, 'd, R: RuleType, D> ParseInput<'i, 'd, R, D> { pub fn as_rule(&self) -> R { self.pair.as_rule() } - pub fn as_rule_alias<C>(&self) -> String + pub fn as_rule_alias<C>(&self) -> C::AliasedRule where C: PestConsumer<Rule = R>, <C as PestConsumer>::Parser: PestParser<R>, @@ -104,7 +104,7 @@ impl<'i, 'd, R: RuleType, D> ParseInputs<'i, 'd, R, D> { self.span.clone(), ) } - pub fn aliased_rules<C>(&self) -> Vec<String> + pub fn aliased_rules<C>(&self) -> Vec<C::AliasedRule> where C: PestConsumer<Rule = R>, <C as PestConsumer>::Parser: PestParser<R>, @@ -120,8 +120,9 @@ impl<'i, 'd, R: RuleType, D> ParseInputs<'i, 'd, R, D> { /// Used by the macros. pub trait PestConsumer { type Rule: RuleType; + type AliasedRule: RuleType; type Parser: PestParser<Self::Rule>; - fn rule_alias(rule: Self::Rule) -> String; + fn rule_alias(rule: Self::Rule) -> Self::AliasedRule; fn allows_shortcut(rule: Self::Rule) -> bool; fn parse_with_userdata<'i, 'd, D>( |