summaryrefslogtreecommitdiffstats
path: root/crates/rebel-parse
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-05-01 19:45:58 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-05-01 20:04:25 +0200
commit0d980906852c9a22120c1b7992d2cc0661a63a80 (patch)
tree993260145403cd5e61c18890f5af0703cab1084f /crates/rebel-parse
parentc21ee9627b9d6f22139a499a30fcc262f7450c08 (diff)
downloadrebel-0d980906852c9a22120c1b7992d2cc0661a63a80.tar
rebel-0d980906852c9a22120c1b7992d2cc0661a63a80.zip
rebel-lang: reuse assignment code for let statements
This should ensure that let with expression is always equivalent to let + separate initialization.
Diffstat (limited to 'crates/rebel-parse')
-rw-r--r--crates/rebel-parse/src/ast/pat.rs12
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],
+ }),
+ }
+ }
+}