From bcfce4aaec48833b2bcf675c6caeb1a81185189e Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 19 Mar 2019 19:06:37 +0200 Subject: [PATCH] Add trailing commas to match arm blocks --- rustfmt.toml | 3 ++- src/token/mod.rs | 14 +++++++------- src/tree/mod.rs | 8 ++++---- src/value/display.rs | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index 966d4aa..e1b078b 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -2,4 +2,5 @@ edition = "2018" reorder_imports=true reorder_modules=true format_strings=true -merge_imports=true \ No newline at end of file +merge_imports=true +match_block_trailing_comma=true \ No newline at end of file diff --git a/src/token/mod.rs b/src/token/mod.rs index d5f5c1d..bc5ca51 100644 --- a/src/token/mod.rs +++ b/src/token/mod.rs @@ -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, Error> { PartialToken::Token(token) => { cutoff = 1; Some(token) - } + }, PartialToken::Literal(literal) => { cutoff = 1; if let Ok(number) = literal.parse::() { @@ -195,11 +195,11 @@ fn resolve_literals(mut tokens: &[PartialToken]) -> Result, 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, 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), diff --git a/src/tree/mod.rs b/src/tree/mod.rs index b286335..2a9f6be 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs @@ -97,7 +97,7 @@ pub fn tokens_to_operator_tree(tokens: Vec) -> Result { } 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) -> Result { 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) -> Result { } } 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)))), diff --git a/src/value/display.rs b/src/value/display.rs index 172ff75..d8595f1 100644 --- a/src/value/display.rs +++ b/src/value/display.rs @@ -20,7 +20,7 @@ impl Display for Value { value.fmt(f)?; } write!(f, ")") - } + }, } } }