Match multiple patterns

This commit is contained in:
2026-05-19 12:21:20 +02:00
parent 318480f0b5
commit bffc9f073b
4 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ pub enum Statement {
iterator: Expression,
body: Box<Statement>,
},
Match(Expression, Vec<(Pattern, Block)>),
Match(Expression, Vec<(Vec<Pattern>, Block)>),
Return(Option<Expression>),
Break,
+3 -1
View File
@@ -446,8 +446,10 @@ for_stmt = {
// MATCH
// ------------------------------------------------------
pattern_list = { pattern ~ ("|" ~ pattern)* }
match_item = {
pattern ~ "=>" ~ block
pattern_list ~ "=>" ~ block
}
match_stmt = {
+1 -1
View File
@@ -100,7 +100,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Statement {
.map(|match_itms| {
let mut match_inner = match_itms.into_inner();
Ok((
Pattern::try_from(match_inner.next().unwrap()).get()?,
collect_recovered(match_inner.next().unwrap().into_inner()).get()?,
Block::try_from(match_inner.next().unwrap()).get()?,
))
})