Skip to content

Commit 1f60a34

Browse files
committed
fix clippy
Change-Id: I41f9e0bf81b34a0c5bc17a2e2b2ede7336eee75f
1 parent f11fb7d commit 1f60a34

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ DUCKDB_LIB_DIR = /Users/wangfenjin/duckdb
77
DUCKDB_INCLUDE_DIR = /Users/wangfenjin/duckdb
88

99
all:
10-
cargo test --features buildtime_bindgen -- --nocapture
11-
cargo clippy --all-targets --workspace --features buildtime_bindgen -- -D warnings -A clippy::redundant-closure
10+
cargo test --features buildtime_bindgen --features modern-full -- --nocapture
11+
cargo clippy --all-targets --workspace --features buildtime_bindgen --features modern-full -- -D warnings -A clippy::redundant-closure

src/types/chrono.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ impl FromSql for NaiveDateTime {
5757
ValueRef::Timestamp(tu, t) => {
5858
let (secs, nsecs) = match tu {
5959
TimeUnit::Second => (t, 0),
60-
TimeUnit::Millisecond => (t / 1000, (t % 1000) * 1000_000),
61-
TimeUnit::Microsecond => (t / 1000_000, (t % 1000_000) * 1000),
62-
TimeUnit::Nanosecond => (t / 1000_000_000, t % 1000_000_000),
60+
TimeUnit::Millisecond => (t / 1000, (t % 1000) * 1_000_000),
61+
TimeUnit::Microsecond => (t / 1_000_000, (t % 1_000_000) * 1000),
62+
TimeUnit::Nanosecond => (t / 1_000_000_000, t % 1_000_000_000),
6363
};
6464
Ok(NaiveDateTime::from_timestamp(secs, nsecs as u32))
6565
}

src/types/from_sql.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -171,22 +171,12 @@ impl FromSql for String {
171171
#[inline]
172172
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
173173
match value {
174-
ValueRef::Date32(d) => {
175-
if cfg!(feature = "chrono") {
176-
Ok(chrono::NaiveDate::column_result(value)?.format("%F").to_string())
177-
} else {
178-
Ok(d.to_string())
179-
}
180-
}
181-
ValueRef::Timestamp(_, t) => {
182-
if cfg!(feature = "chrono") {
183-
Ok(chrono::NaiveDateTime::column_result(value)?
184-
.format("%F %T%.f")
185-
.to_string())
186-
} else {
187-
Ok(t.to_string())
188-
}
189-
}
174+
#[cfg(feature = "chrono")]
175+
ValueRef::Date32(_) => Ok(chrono::NaiveDate::column_result(value)?.format("%F").to_string()),
176+
#[cfg(feature = "chrono")]
177+
ValueRef::Timestamp(..) => Ok(chrono::NaiveDateTime::column_result(value)?
178+
.format("%F %T%.f")
179+
.to_string()),
190180
_ => value.as_str().map(ToString::to_string),
191181
}
192182
}

0 commit comments

Comments
 (0)