diff options
Diffstat (limited to 'crates/rebel-parse/src/ast/pat.rs')
-rw-r--r-- | crates/rebel-parse/src/ast/pat.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/rebel-parse/src/ast/pat.rs b/crates/rebel-parse/src/ast/pat.rs index 7365b19..7528185 100644 --- a/crates/rebel-parse/src/ast/pat.rs +++ b/crates/rebel-parse/src/ast/pat.rs @@ -43,3 +43,15 @@ impl<'a> DestrPat<'a> { } } } + +impl<'a> From<&Pat<'a>> for DestrPat<'a> { + fn from(value: &Pat<'a>) -> Self { + match value { + Pat::Paren(pat) => DestrPat::Paren(Box::new(pat.as_ref().into())), + Pat::Ident(ident) => DestrPat::Path(Path { + root: PathRoot::Relative, + components: vec![*ident], + }), + } + } +} |