From 2ddf9349ef5258498ca5ca43e9852fefeb038f8c Mon Sep 17 00:00:00 2001 From: chitao1234 Date: Mon, 15 Sep 2025 12:03:09 +0800 Subject: fix: clippy warnings --- crates/atuin-client/src/database.rs | 10 ++--- .../src/command/client/search/engines/skim.rs | 44 +++++++++------------- 2 files changed, 22 insertions(+), 32 deletions(-) (limited to 'crates') diff --git a/crates/atuin-client/src/database.rs b/crates/atuin-client/src/database.rs index 3c88350f..82644182 100644 --- a/crates/atuin-client/src/database.rs +++ b/crates/atuin-client/src/database.rs @@ -77,11 +77,11 @@ pub fn current_context() -> Context { } fn get_session_start_time(session_id: &str) -> Option { - if let Ok(uuid) = Uuid::parse_str(session_id) { - if let Some(timestamp) = uuid.get_timestamp() { - let (seconds, nanos) = timestamp.to_unix(); - return Some(seconds as i64 * 1_000_000_000 + nanos as i64); - } + if let Ok(uuid) = Uuid::parse_str(session_id) + && let Some(timestamp) = uuid.get_timestamp() + { + let (seconds, nanos) = timestamp.to_unix(); + return Some(seconds as i64 * 1_000_000_000 + nanos as i64); } None } diff --git a/crates/atuin/src/command/client/search/engines/skim.rs b/crates/atuin/src/command/client/search/engines/skim.rs index dcf06e61..1af49574 100644 --- a/crates/atuin/src/command/client/search/engines/skim.rs +++ b/crates/atuin/src/command/client/search/engines/skim.rs @@ -48,6 +48,7 @@ impl SearchEngine for Search { } } +#[allow(clippy::too_many_lines)] async fn fuzzy_search( engine: &SkimMatcherV2, state: &SearchState, @@ -95,36 +96,25 @@ async fn fuzzy_search( }; if !is_current_session { - let uuid = match uuid::Uuid::parse_str(&context.session) { - Ok(uuid) => uuid, - Err(_) => { - log::warn!("failed to parse session id '{}'", context.session); - continue; - } + let Ok(uuid) = uuid::Uuid::parse_str(&context.session) else { + log::warn!("failed to parse session id '{}'", context.session); + continue; }; - let timestamp = match uuid.get_timestamp() { - Some(timestamp) => timestamp, - None => { - log::warn!( - "failed to get timestamp from uuid '{}'", - uuid.as_hyphenated() - ); - continue; - } + let Some(timestamp) = uuid.get_timestamp() else { + log::warn!( + "failed to get timestamp from uuid '{}'", + uuid.as_hyphenated() + ); + continue; }; let (seconds, nanos) = timestamp.to_unix(); - let session_start = match time::OffsetDateTime::from_unix_timestamp_nanos( - seconds as i128 * 1_000_000_000 + nanos as i128, - ) { - Ok(session_start) => session_start, - Err(_) => { - log::warn!( - "failed to create OffsetDateTime from second: {}, nanosecond: {}", - seconds, - nanos - ); - continue; - } + let Ok(session_start) = time::OffsetDateTime::from_unix_timestamp_nanos( + i128::from(seconds) * 1_000_000_000 + i128::from(nanos), + ) else { + log::warn!( + "failed to create OffsetDateTime from second: {seconds}, nanosecond: {nanos}" + ); + continue; }; if history.timestamp >= session_start { -- cgit v1.3.1