From 43aca1b492ac5ac26a2b2143af94b24dee20ab2c Mon Sep 17 00:00:00 2001 From: James Musselman Date: Mon, 16 Dec 2024 22:40:31 -0600 Subject: [PATCH] Remove some clippy issues --- examples/provider-sync.rs | 8 ++++---- examples/shared.rs | 21 +++++++++++---------- examples/toggle-completions.rs | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/examples/provider-sync.rs b/examples/provider-sync.rs index 4e6cd3c..a117272 100644 --- a/examples/provider-sync.rs +++ b/examples/provider-sync.rs @@ -27,7 +27,7 @@ async fn main() { println!("This example show how to sync a remote server with a local cache, using a Provider."); println!("Make sure you have edited the constants in the 'shared.rs' file to include correct URLs and credentials."); println!("You can also set the RUST_LOG environment variable to display more info about the sync."); - println!(""); + println!(); println!("This will use the following settings:"); println!(" * URL = {}", URL); println!(" * USERNAME = {}", USERNAME); @@ -69,7 +69,7 @@ async fn add_items_and_sync_again(provider: &mut CalDavProvider) { .lock().unwrap().add_item(Item::Task(new_task)).await.unwrap(); - if provider.sync().await == false { + if !(provider.sync().await) { log::warn!("Sync did not complete, see the previous log lines for more info. You can safely start a new sync. The new task may not have been synced."); } else { println!("Done syncing the new task '{}' and the new calendar '{}'", new_task_name, new_calendar_name); @@ -93,7 +93,7 @@ async fn complete_item_and_sync_again( .unwrap_task_mut() .set_completion_status(completion_status); - if provider.sync().await == false { + if !(provider.sync().await) { log::warn!("Sync did not complete, see the previous log lines for more info. You can safely start a new sync. The new task may not have been synced."); } else { println!("Done syncing the completed task"); @@ -116,7 +116,7 @@ async fn remove_items_and_sync_again( .lock().unwrap() .mark_for_deletion(id_to_remove).await.unwrap(); - if provider.sync().await == false { + if !(provider.sync().await) { log::warn!("Sync did not complete, see the previous log lines for more info. You can safely start a new sync. The new task may not have been synced."); } else { println!("Done syncing the deleted task"); diff --git a/examples/shared.rs b/examples/shared.rs index 3cb7f2e..74aa2d8 100644 --- a/examples/shared.rs +++ b/examples/shared.rs @@ -1,47 +1,48 @@ use std::path::Path; +use kitchen_fridge::cache::Cache; use kitchen_fridge::client::Client; use kitchen_fridge::traits::CalDavSource; use kitchen_fridge::CalDavProvider; -use kitchen_fridge::cache::Cache; - // TODO: change these values with yours pub const URL: &str = "https://my.server.com/remote.php/dav/files/john"; pub const USERNAME: &str = "username"; pub const PASSWORD: &str = "secret_password"; -pub const EXAMPLE_EXISTING_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_name/"; -pub const EXAMPLE_CREATED_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_that_we_have_created/"; +pub const EXAMPLE_EXISTING_CALENDAR_URL: &str = + "https://my.server.com/remote.php/dav/calendars/john/a_calendar_name/"; +pub const EXAMPLE_CREATED_CALENDAR_URL: &str = + "https://my.server.com/remote.php/dav/calendars/john/a_calendar_that_we_have_created/"; fn main() { panic!("This file is not supposed to be executed"); } - /// Initializes a Provider, and run an initial sync from the server pub async fn initial_sync(cache_folder: &str) -> CalDavProvider { let cache_path = Path::new(cache_folder); let client = Client::new(URL, USERNAME, PASSWORD).unwrap(); - let cache = match Cache::from_folder(&cache_path) { + let cache = match Cache::from_folder(cache_path) { Ok(cache) => cache, Err(err) => { log::warn!("Invalid cache file: {}. Using a default cache", err); - Cache::new(&cache_path) + Cache::new(cache_path) } }; let mut provider = CalDavProvider::new(client, cache); - let cals = provider.local().get_calendars().await.unwrap(); println!("---- Local items, before sync -----"); kitchen_fridge::utils::print_calendar_list(&cals).await; println!("Starting a sync..."); - println!("Depending on your RUST_LOG value, you may see more or less details about the progress."); + println!( + "Depending on your RUST_LOG value, you may see more or less details about the progress." + ); // Note that we could use sync_with_feedback() to have better and formatted feedback - if provider.sync().await == false { + if !(provider.sync().await) { log::warn!("Sync did not complete, see the previous log lines for more info. You can safely start a new sync."); } provider.local().save_to_folder().unwrap(); diff --git a/examples/toggle-completions.rs b/examples/toggle-completions.rs index 592f608..1f042cc 100644 --- a/examples/toggle-completions.rs +++ b/examples/toggle-completions.rs @@ -23,7 +23,7 @@ async fn main() { println!("This example show how to sync a remote server with a local cache, using a Provider."); println!("Make sure you have edited the constants in the 'shared.rs' file to include correct URLs and credentials."); println!("You can also set the RUST_LOG environment variable to display more info about the sync."); - println!(""); + println!(); println!("This will use the following settings:"); println!(" * URL = {}", URL); println!(" * USERNAME = {}", USERNAME);