Skip to content

Commit 7fa9105

Browse files
committed
chore: clippy fix
1 parent b56331d commit 7fa9105

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

rust/cubesql/pg-srv/src/timestamp.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use chrono::{
1212
};
1313
use chrono_tz::Tz;
1414
use std::{
15-
fmt::{self, Debug, Formatter},
15+
fmt::{self, Debug, Display, Formatter},
1616
io,
1717
};
1818

@@ -70,27 +70,26 @@ impl Debug for TimestampValue {
7070
}
7171
}
7272

73-
impl ToString for TimestampValue {
74-
fn to_string(&self) -> String {
75-
Utc.timestamp_nanos(self.unix_nano)
76-
.format_with_items(
77-
[
78-
Item::Numeric(Year, Zero),
79-
Item::Literal("-"),
80-
Item::Numeric(Month, Zero),
81-
Item::Literal("-"),
82-
Item::Numeric(Day, Zero),
83-
Item::Literal("T"),
84-
Item::Numeric(Hour, Zero),
85-
Item::Literal(":"),
86-
Item::Numeric(Minute, Zero),
87-
Item::Literal(":"),
88-
Item::Numeric(Second, Zero),
89-
Item::Fixed(Fixed::Nanosecond3),
90-
]
91-
.iter(),
92-
)
93-
.to_string()
73+
impl Display for TimestampValue {
74+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
75+
let formatted = Utc.timestamp_nanos(self.unix_nano).format_with_items(
76+
[
77+
Item::Numeric(Year, Zero),
78+
Item::Literal("-"),
79+
Item::Numeric(Month, Zero),
80+
Item::Literal("-"),
81+
Item::Numeric(Day, Zero),
82+
Item::Literal("T"),
83+
Item::Numeric(Hour, Zero),
84+
Item::Literal(":"),
85+
Item::Numeric(Minute, Zero),
86+
Item::Literal(":"),
87+
Item::Numeric(Second, Zero),
88+
Item::Fixed(Fixed::Nanosecond3),
89+
]
90+
.iter(),
91+
);
92+
write!(f, "{}", formatted)
9493
}
9594
}
9695

0 commit comments

Comments
 (0)