Skip to content

Commit 1b31f03

Browse files
committed
Change write! to write_str for better rustfmt formatting
1 parent 275e6b1 commit 1b31f03

File tree

4 files changed

+58
-90
lines changed

4 files changed

+58
-90
lines changed

src/ast/mod.rs

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -660,19 +660,15 @@ pub enum FileFormat {
660660
impl fmt::Display for FileFormat {
661661
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
662662
use self::FileFormat::*;
663-
write!(
664-
f,
665-
"{}",
666-
match self {
667-
TEXTFILE => "TEXTFILE",
668-
SEQUENCEFILE => "SEQUENCEFILE",
669-
ORC => "ORC",
670-
PARQUET => "PARQUET",
671-
AVRO => "AVRO",
672-
RCFILE => "RCFILE",
673-
JSONFILE => "TEXTFILE",
674-
}
675-
)
663+
f.write_str(match self {
664+
TEXTFILE => "TEXTFILE",
665+
SEQUENCEFILE => "SEQUENCEFILE",
666+
ORC => "ORC",
667+
PARQUET => "PARQUET",
668+
AVRO => "AVRO",
669+
RCFILE => "RCFILE",
670+
JSONFILE => "TEXTFILE",
671+
})
676672
}
677673
}
678674

@@ -707,14 +703,10 @@ pub enum ObjectType {
707703

708704
impl fmt::Display for ObjectType {
709705
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
710-
write!(
711-
f,
712-
"{}",
713-
match self {
714-
ObjectType::Table => "TABLE",
715-
ObjectType::View => "VIEW",
716-
}
717-
)
706+
f.write_str(match self {
707+
ObjectType::Table => "TABLE",
708+
ObjectType::View => "VIEW",
709+
})
718710
}
719711
}
720712

@@ -755,14 +747,10 @@ pub enum TransactionAccessMode {
755747
impl fmt::Display for TransactionAccessMode {
756748
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
757749
use TransactionAccessMode::*;
758-
write!(
759-
f,
760-
"{}",
761-
match self {
762-
ReadOnly => "READ ONLY",
763-
ReadWrite => "READ WRITE",
764-
}
765-
)
750+
f.write_str(match self {
751+
ReadOnly => "READ ONLY",
752+
ReadWrite => "READ WRITE",
753+
})
766754
}
767755
}
768756

@@ -777,15 +765,11 @@ pub enum TransactionIsolationLevel {
777765
impl fmt::Display for TransactionIsolationLevel {
778766
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
779767
use TransactionIsolationLevel::*;
780-
write!(
781-
f,
782-
"{}",
783-
match self {
784-
ReadUncommitted => "READ UNCOMMITTED",
785-
ReadCommitted => "READ COMMITTED",
786-
RepeatableRead => "REPEATABLE READ",
787-
Serializable => "SERIALIZABLE",
788-
}
789-
)
768+
f.write_str(match self {
769+
ReadUncommitted => "READ UNCOMMITTED",
770+
ReadCommitted => "READ COMMITTED",
771+
RepeatableRead => "REPEATABLE READ",
772+
Serializable => "SERIALIZABLE",
773+
})
790774
}
791775
}

src/ast/operator.rs

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@ pub enum UnaryOperator {
2222

2323
impl fmt::Display for UnaryOperator {
2424
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
25-
write!(
26-
f,
27-
"{}",
28-
match self {
29-
UnaryOperator::Plus => "+",
30-
UnaryOperator::Minus => "-",
31-
UnaryOperator::Not => "NOT",
32-
}
33-
)
25+
f.write_str(match self {
26+
UnaryOperator::Plus => "+",
27+
UnaryOperator::Minus => "-",
28+
UnaryOperator::Not => "NOT",
29+
})
3430
}
3531
}
3632

@@ -56,26 +52,22 @@ pub enum BinaryOperator {
5652

5753
impl fmt::Display for BinaryOperator {
5854
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
59-
write!(
60-
f,
61-
"{}",
62-
match self {
63-
BinaryOperator::Plus => "+",
64-
BinaryOperator::Minus => "-",
65-
BinaryOperator::Multiply => "*",
66-
BinaryOperator::Divide => "/",
67-
BinaryOperator::Modulus => "%",
68-
BinaryOperator::Gt => ">",
69-
BinaryOperator::Lt => "<",
70-
BinaryOperator::GtEq => ">=",
71-
BinaryOperator::LtEq => "<=",
72-
BinaryOperator::Eq => "=",
73-
BinaryOperator::NotEq => "<>",
74-
BinaryOperator::And => "AND",
75-
BinaryOperator::Or => "OR",
76-
BinaryOperator::Like => "LIKE",
77-
BinaryOperator::NotLike => "NOT LIKE",
78-
}
79-
)
55+
f.write_str(match self {
56+
BinaryOperator::Plus => "+",
57+
BinaryOperator::Minus => "-",
58+
BinaryOperator::Multiply => "*",
59+
BinaryOperator::Divide => "/",
60+
BinaryOperator::Modulus => "%",
61+
BinaryOperator::Gt => ">",
62+
BinaryOperator::Lt => "<",
63+
BinaryOperator::GtEq => ">=",
64+
BinaryOperator::LtEq => "<=",
65+
BinaryOperator::Eq => "=",
66+
BinaryOperator::NotEq => "<>",
67+
BinaryOperator::And => "AND",
68+
BinaryOperator::Or => "OR",
69+
BinaryOperator::Like => "LIKE",
70+
BinaryOperator::NotLike => "NOT LIKE",
71+
})
8072
}
8173
}

src/ast/query.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,11 @@ pub enum SetOperator {
100100

101101
impl fmt::Display for SetOperator {
102102
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
103-
write!(
104-
f,
105-
"{}",
106-
match self {
107-
SetOperator::Union => "UNION",
108-
SetOperator::Except => "EXCEPT",
109-
SetOperator::Intersect => "INTERSECT",
110-
}
111-
)
103+
f.write_str(match self {
104+
SetOperator::Union => "UNION",
105+
SetOperator::Except => "EXCEPT",
106+
SetOperator::Intersect => "INTERSECT",
107+
})
112108
}
113109
}
114110

src/ast/value.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,14 @@ pub enum DateTimeField {
128128

129129
impl fmt::Display for DateTimeField {
130130
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
131-
write!(
132-
f,
133-
"{}",
134-
match self {
135-
DateTimeField::Year => "YEAR",
136-
DateTimeField::Month => "MONTH",
137-
DateTimeField::Day => "DAY",
138-
DateTimeField::Hour => "HOUR",
139-
DateTimeField::Minute => "MINUTE",
140-
DateTimeField::Second => "SECOND",
141-
}
142-
)
131+
f.write_str(match self {
132+
DateTimeField::Year => "YEAR",
133+
DateTimeField::Month => "MONTH",
134+
DateTimeField::Day => "DAY",
135+
DateTimeField::Hour => "HOUR",
136+
DateTimeField::Minute => "MINUTE",
137+
DateTimeField::Second => "SECOND",
138+
})
143139
}
144140
}
145141

0 commit comments

Comments
 (0)