Add trailing commas to match arm blocks

This commit is contained in:
Sebastian Schmidt 2019-03-19 19:06:37 +02:00
parent f0ab317961
commit bcfce4aaec
4 changed files with 14 additions and 13 deletions

View File

@ -3,3 +3,4 @@ reorder_imports=true
reorder_modules=true
format_strings=true
merge_imports=true
match_block_trailing_comma=true

View File

@ -77,7 +77,7 @@ fn char_to_partial_token(c: char) -> PartialToken {
} else {
PartialToken::Literal(c.to_string())
}
}
},
}
}
@ -183,7 +183,7 @@ fn resolve_literals(mut tokens: &[PartialToken]) -> Result<Vec<Token>, Error> {
PartialToken::Token(token) => {
cutoff = 1;
Some(token)
}
},
PartialToken::Literal(literal) => {
cutoff = 1;
if let Ok(number) = literal.parse::<IntType>() {
@ -195,11 +195,11 @@ fn resolve_literals(mut tokens: &[PartialToken]) -> Result<Vec<Token>, Error> {
} else {
Some(Token::Identifier(literal.to_string()))
}
}
},
PartialToken::Whitespace => {
cutoff = 1;
None
}
},
PartialToken::Eq => match second {
Some(PartialToken::Eq) => Some(Token::Eq),
_ => return Err(Error::unmatched_partial_token(first, second)),
@ -209,21 +209,21 @@ fn resolve_literals(mut tokens: &[PartialToken]) -> Result<Vec<Token>, Error> {
_ => {
cutoff = 1;
Some(Token::Not)
}
},
},
PartialToken::Gt => match second {
Some(PartialToken::Eq) => Some(Token::Geq),
_ => {
cutoff = 1;
Some(Token::Gt)
}
},
},
PartialToken::Lt => match second {
Some(PartialToken::Eq) => Some(Token::Leq),
_ => {
cutoff = 1;
Some(Token::Lt)
}
},
},
PartialToken::Ampersand => match second {
Some(PartialToken::Ampersand) => Some(Token::And),

View File

@ -97,7 +97,7 @@ pub fn tokens_to_operator_tree(tokens: Vec<Token>) -> Result<Node, Error> {
} else {
Some(Node::new(Neg))
}
}
},
Token::Star => Some(Node::new(Mul)),
Token::Slash => Some(Node::new(Div)),
Token::Percent => Some(Node::new(Mod)),
@ -116,14 +116,14 @@ pub fn tokens_to_operator_tree(tokens: Vec<Token>) -> Result<Node, Error> {
Token::LBrace => {
root.push(Node::root_node());
None
}
},
Token::RBrace => {
if root.len() < 2 {
return Err(Error::UnmatchedRBrace);
} else {
root.pop()
}
}
},
Token::Comma => Some(Node::new(Tuple)),
@ -135,7 +135,7 @@ pub fn tokens_to_operator_tree(tokens: Vec<Token>) -> Result<Node, Error> {
}
}
result
}
},
Token::Float(number) => Some(Node::new(Const::new(Value::Float(number)))),
Token::Int(number) => Some(Node::new(Const::new(Value::Int(number)))),
Token::Boolean(boolean) => Some(Node::new(Const::new(Value::Boolean(boolean)))),

View File

@ -20,7 +20,7 @@ impl Display for Value {
value.fmt(f)?;
}
write!(f, ")")
}
},
}
}
}