From 1b31f0373237cbf1d6e2ec163dc991e30db8f246 Mon Sep 17 00:00:00 2001 From: Nickolay Ponomarev Date: Sun, 7 Jul 2019 03:22:30 +0300 Subject: [PATCH] Change write! to write_str for better rustfmt formatting --- src/ast/mod.rs | 62 +++++++++++++++++---------------------------- src/ast/operator.rs | 52 ++++++++++++++++--------------------- src/ast/query.rs | 14 ++++------ src/ast/value.rs | 20 ++++++--------- 4 files changed, 58 insertions(+), 90 deletions(-) diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 33010d2f..79d78087 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -660,19 +660,15 @@ pub enum FileFormat { impl fmt::Display for FileFormat { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use self::FileFormat::*; - write!( - f, - "{}", - match self { - TEXTFILE => "TEXTFILE", - SEQUENCEFILE => "SEQUENCEFILE", - ORC => "ORC", - PARQUET => "PARQUET", - AVRO => "AVRO", - RCFILE => "RCFILE", - JSONFILE => "TEXTFILE", - } - ) + f.write_str(match self { + TEXTFILE => "TEXTFILE", + SEQUENCEFILE => "SEQUENCEFILE", + ORC => "ORC", + PARQUET => "PARQUET", + AVRO => "AVRO", + RCFILE => "RCFILE", + JSONFILE => "TEXTFILE", + }) } } @@ -707,14 +703,10 @@ pub enum ObjectType { impl fmt::Display for ObjectType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "{}", - match self { - ObjectType::Table => "TABLE", - ObjectType::View => "VIEW", - } - ) + f.write_str(match self { + ObjectType::Table => "TABLE", + ObjectType::View => "VIEW", + }) } } @@ -755,14 +747,10 @@ pub enum TransactionAccessMode { impl fmt::Display for TransactionAccessMode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use TransactionAccessMode::*; - write!( - f, - "{}", - match self { - ReadOnly => "READ ONLY", - ReadWrite => "READ WRITE", - } - ) + f.write_str(match self { + ReadOnly => "READ ONLY", + ReadWrite => "READ WRITE", + }) } } @@ -777,15 +765,11 @@ pub enum TransactionIsolationLevel { impl fmt::Display for TransactionIsolationLevel { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use TransactionIsolationLevel::*; - write!( - f, - "{}", - match self { - ReadUncommitted => "READ UNCOMMITTED", - ReadCommitted => "READ COMMITTED", - RepeatableRead => "REPEATABLE READ", - Serializable => "SERIALIZABLE", - } - ) + f.write_str(match self { + ReadUncommitted => "READ UNCOMMITTED", + ReadCommitted => "READ COMMITTED", + RepeatableRead => "REPEATABLE READ", + Serializable => "SERIALIZABLE", + }) } } diff --git a/src/ast/operator.rs b/src/ast/operator.rs index 747cfd9e..f2970482 100644 --- a/src/ast/operator.rs +++ b/src/ast/operator.rs @@ -22,15 +22,11 @@ pub enum UnaryOperator { impl fmt::Display for UnaryOperator { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "{}", - match self { - UnaryOperator::Plus => "+", - UnaryOperator::Minus => "-", - UnaryOperator::Not => "NOT", - } - ) + f.write_str(match self { + UnaryOperator::Plus => "+", + UnaryOperator::Minus => "-", + UnaryOperator::Not => "NOT", + }) } } @@ -56,26 +52,22 @@ pub enum BinaryOperator { impl fmt::Display for BinaryOperator { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "{}", - match self { - BinaryOperator::Plus => "+", - BinaryOperator::Minus => "-", - BinaryOperator::Multiply => "*", - BinaryOperator::Divide => "/", - BinaryOperator::Modulus => "%", - BinaryOperator::Gt => ">", - BinaryOperator::Lt => "<", - BinaryOperator::GtEq => ">=", - BinaryOperator::LtEq => "<=", - BinaryOperator::Eq => "=", - BinaryOperator::NotEq => "<>", - BinaryOperator::And => "AND", - BinaryOperator::Or => "OR", - BinaryOperator::Like => "LIKE", - BinaryOperator::NotLike => "NOT LIKE", - } - ) + f.write_str(match self { + BinaryOperator::Plus => "+", + BinaryOperator::Minus => "-", + BinaryOperator::Multiply => "*", + BinaryOperator::Divide => "/", + BinaryOperator::Modulus => "%", + BinaryOperator::Gt => ">", + BinaryOperator::Lt => "<", + BinaryOperator::GtEq => ">=", + BinaryOperator::LtEq => "<=", + BinaryOperator::Eq => "=", + BinaryOperator::NotEq => "<>", + BinaryOperator::And => "AND", + BinaryOperator::Or => "OR", + BinaryOperator::Like => "LIKE", + BinaryOperator::NotLike => "NOT LIKE", + }) } } diff --git a/src/ast/query.rs b/src/ast/query.rs index e1f2637d..656f7f14 100644 --- a/src/ast/query.rs +++ b/src/ast/query.rs @@ -100,15 +100,11 @@ pub enum SetOperator { impl fmt::Display for SetOperator { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "{}", - match self { - SetOperator::Union => "UNION", - SetOperator::Except => "EXCEPT", - SetOperator::Intersect => "INTERSECT", - } - ) + f.write_str(match self { + SetOperator::Union => "UNION", + SetOperator::Except => "EXCEPT", + SetOperator::Intersect => "INTERSECT", + }) } } diff --git a/src/ast/value.rs b/src/ast/value.rs index f0e418a2..b406dfe4 100644 --- a/src/ast/value.rs +++ b/src/ast/value.rs @@ -128,18 +128,14 @@ pub enum DateTimeField { impl fmt::Display for DateTimeField { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "{}", - match self { - DateTimeField::Year => "YEAR", - DateTimeField::Month => "MONTH", - DateTimeField::Day => "DAY", - DateTimeField::Hour => "HOUR", - DateTimeField::Minute => "MINUTE", - DateTimeField::Second => "SECOND", - } - ) + f.write_str(match self { + DateTimeField::Year => "YEAR", + DateTimeField::Month => "MONTH", + DateTimeField::Day => "DAY", + DateTimeField::Hour => "HOUR", + DateTimeField::Minute => "MINUTE", + DateTimeField::Second => "SECOND", + }) } }