diff options
author | 2022-07-09 18:42:41 +0200 | |
---|---|---|
committer | 2022-07-09 18:43:05 +0200 | |
commit | 2065a40f642589134142a740ff4198deaa4c378b (patch) | |
tree | 00477d6d7cb571332062535557151d5b031d8925 /examples/todos | |
parent | d53cc5498b92fb6b573867f5ccb5f8ac93f6be79 (diff) | |
download | iced-2065a40f642589134142a740ff4198deaa4c378b.tar.gz iced-2065a40f642589134142a740ff4198deaa4c378b.tar.bz2 iced-2065a40f642589134142a740ff4198deaa4c378b.zip |
Fix `clippy` lints for all crates and features
... and check those in CI as well!
Diffstat (limited to 'examples/todos')
-rw-r--r-- | examples/todos/src/main.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index dc080ef5..7bfc2a34 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -168,7 +168,7 @@ impl Application for Todos { .size(30) .on_submit(Message::CreateTask); - let controls = controls.view(&tasks, *filter); + let controls = controls.view(tasks, *filter); let filtered_tasks = tasks.iter().filter(|task| filter.matches(task)); @@ -493,15 +493,15 @@ struct SavedState { #[derive(Debug, Clone)] enum LoadError { - FileError, - FormatError, + File, + Format, } #[derive(Debug, Clone)] enum SaveError { - FileError, - WriteError, - FormatError, + File, + Write, + Format, } #[cfg(not(target_arch = "wasm32"))] @@ -512,7 +512,7 @@ impl SavedState { { project_dirs.data_dir().into() } else { - std::env::current_dir().unwrap_or(std::path::PathBuf::new()) + std::env::current_dir().unwrap_or_default() }; path.push("todos.json"); @@ -527,37 +527,37 @@ impl SavedState { let mut file = async_std::fs::File::open(Self::path()) .await - .map_err(|_| LoadError::FileError)?; + .map_err(|_| LoadError::File)?; file.read_to_string(&mut contents) .await - .map_err(|_| LoadError::FileError)?; + .map_err(|_| LoadError::File)?; - serde_json::from_str(&contents).map_err(|_| LoadError::FormatError) + serde_json::from_str(&contents).map_err(|_| LoadError::Format) } async fn save(self) -> Result<(), SaveError> { use async_std::prelude::*; let json = serde_json::to_string_pretty(&self) - .map_err(|_| SaveError::FormatError)?; + .map_err(|_| SaveError::Format)?; let path = Self::path(); if let Some(dir) = path.parent() { async_std::fs::create_dir_all(dir) .await - .map_err(|_| SaveError::FileError)?; + .map_err(|_| SaveError::File)?; } { let mut file = async_std::fs::File::create(path) .await - .map_err(|_| SaveError::FileError)?; + .map_err(|_| SaveError::File)?; file.write_all(json.as_bytes()) .await - .map_err(|_| SaveError::WriteError)?; + .map_err(|_| SaveError::Write)?; } // This is a simple way to save at most once every couple seconds |