From 17ac6cfbf16a427e53a683278742cb0a90c977bc Mon Sep 17 00:00:00 2001 From: Dominykas Djacenko Date: Sun, 18 Feb 2024 23:16:34 -0800 Subject: [PATCH] chore: clippy lints --- src/api/sync/data.rs | 5 +--- src/api/sync/mod.rs | 2 -- src/interactive.rs | 52 ++++++++++++++++++++--------------------- src/tasks/filter.rs | 4 ++-- tests/commands/setup.rs | 2 +- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/src/api/sync/data.rs b/src/api/sync/data.rs index e3c5489..83f1da8 100644 --- a/src/api/sync/data.rs +++ b/src/api/sync/data.rs @@ -19,10 +19,7 @@ fn find_id_index(array: &[serde_json::Value], id: u64) -> Option { None } -fn merge_with_deleted_arrays( - original: &mut Vec, - patch: &Vec, -) { +fn merge_with_deleted_arrays(original: &mut Vec, patch: &[serde_json::Value]) { if original.is_empty() && patch.is_empty() { return; } diff --git a/src/api/sync/mod.rs b/src/api/sync/mod.rs index d8095ee..5a14ef5 100644 --- a/src/api/sync/mod.rs +++ b/src/api/sync/mod.rs @@ -3,5 +3,3 @@ //! potential future use. mod data; mod state; - -pub use state::State; diff --git a/src/interactive.rs b/src/interactive.rs index 90a562f..01fffad 100644 --- a/src/interactive.rs +++ b/src/interactive.rs @@ -208,32 +208,6 @@ impl FuzzSelect for Task { } } -#[cfg(test)] -mod test { - use super::*; - - type Selectable<'a> = (i32, &'a str); - - impl<'a> FuzzSelect for Selectable<'a> { - type ID = i32; - - fn id(&self) -> i32 { - self.0 - } - fn name(&self) -> &str { - self.1 - } - } - - #[test] - fn select_best() { - let select: Vec = vec![(0, "zero"), (1, "one"), (2, "two"), (3, "three")]; - assert_eq!(fuzz_select(&select, "one").unwrap().0, 1); - assert_eq!(fuzz_select(&select, "w").unwrap().0, 2); - assert!(fuzz_select(&select, "what").is_err()); - } -} - pub fn input_content(content: &str) -> Result { let mut input = dialoguer::Input::new(); input @@ -305,3 +279,29 @@ pub fn input_priority() -> Result> { let selection = select("Priority", &items)?; Ok(selection.map(|s| items[s])) } + +#[cfg(test)] +mod test { + use super::*; + + type Selectable<'a> = (i32, &'a str); + + impl<'a> FuzzSelect for Selectable<'a> { + type ID = i32; + + fn id(&self) -> i32 { + self.0 + } + fn name(&self) -> &str { + self.1 + } + } + + #[test] + fn select_best() { + let select: Vec = vec![(0, "zero"), (1, "one"), (2, "two"), (3, "three")]; + assert_eq!(fuzz_select(&select, "one").unwrap().0, 1); + assert_eq!(fuzz_select(&select, "w").unwrap().0, 2); + assert!(fuzz_select(&select, "what").is_err()); + } +} diff --git a/src/tasks/filter.rs b/src/tasks/filter.rs index 0e2bbeb..05878d5 100644 --- a/src/tasks/filter.rs +++ b/src/tasks/filter.rs @@ -88,8 +88,8 @@ mod tests { }; let f = Filter::new(None); - assert!(f.select(&cfg) == "all".to_owned()); + assert!(f.select(&cfg) == *"all"); let f = Filter::new(Some("today".to_owned())); - assert!(f.select(&cfg) == "today".to_owned()); + assert!(f.select(&cfg) == *"today"); } } diff --git a/tests/commands/setup.rs b/tests/commands/setup.rs index 0ec26d0..a822f4a 100644 --- a/tests/commands/setup.rs +++ b/tests/commands/setup.rs @@ -22,7 +22,7 @@ impl Tool { .success(); let mock = MockServer::start().await; - let mut cfg = Config::load_prefix(&tmp.path())?; + let mut cfg = Config::load_prefix(tmp.path())?; cfg.url = Some(url::Url::parse(&mock.uri())?); cfg.override_time = Some(super::fixtures::FETCH_TIME.trim().parse()?); cfg.save()?;