Improved match statements
This commit is contained in:
@@ -13,18 +13,13 @@ pub enum LogLevel {
|
||||
|
||||
impl fmt::Display for LogLevel {
|
||||
fmt::Result fmt(self*, Formatter<'_> mut* f) {
|
||||
match (self) {
|
||||
LogLevel::Info => {
|
||||
return write!(f, "[INFO]");
|
||||
}
|
||||
return match (self) {
|
||||
LogLevel::Info => write!(f, "[INFO]");
|
||||
|
||||
LogLevel::Warning => {
|
||||
return write!(f, "[WARN]");
|
||||
}
|
||||
LogLevel::Warning => write!(f, "[WARN]");
|
||||
|
||||
LogLevel::Error => {
|
||||
return write!(f, "[ERROR]");
|
||||
}
|
||||
LogLevel::Error => write!(f, "[ERROR]");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ pub enum Statement {
|
||||
iterator: Expression,
|
||||
body: Box<Statement>,
|
||||
},
|
||||
Match(Expression, Vec<(Vec<Pattern>, Block)>),
|
||||
Match(Expression, Vec<(Vec<Pattern>, Expression)>),
|
||||
|
||||
Return(Option<Expression>),
|
||||
Break,
|
||||
|
||||
@@ -419,7 +419,7 @@ for_stmt = {
|
||||
pattern_list = { pattern ~ ("|" ~ pattern)* }
|
||||
|
||||
match_item = {
|
||||
pattern_list ~ "=>" ~ block
|
||||
pattern_list ~ "=>" ~ statement
|
||||
}
|
||||
|
||||
match_stmt = {
|
||||
|
||||
@@ -95,7 +95,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Statement {
|
||||
let mut match_inner = match_itms.into_inner();
|
||||
Ok((
|
||||
collect_recovered(match_inner.next().unwrap().into_inner()).get()?,
|
||||
Block::try_from(match_inner.next().unwrap()).get()?,
|
||||
Expression::try_from(match_inner.next().unwrap()).get()?,
|
||||
))
|
||||
})
|
||||
.collect::<AstResult<'a, Vec<_>>>(),
|
||||
|
||||
Reference in New Issue
Block a user