From d944a6516ef1aabace35a936f1092a38a1f7292d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 12:50:41 +0000 Subject: [PATCH 1/2] chore(deps): bump serde from 1.0.199 to 1.0.200 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.199 to 1.0.200. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.199...v1.0.200) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fde447b..dda5bca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -510,18 +510,18 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "serde" -version = "1.0.199" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.199" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 08e425c..c9b861e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,6 @@ config = "0.14.0" daemonize = "0.5.0" home = "0.5.9" rand = "0.8.5" -serde = "1.0.199" +serde = "1.0.200" serde_derive = "1.0.188" thiserror = "1.0.59" From 30b982df05eccff0e28747c8fa1ef71fcc065a74 Mon Sep 17 00:00:00 2001 From: Yago Iglesias Date: Mon, 6 May 2024 17:49:50 +0200 Subject: [PATCH 2/2] refactor: Implement Display instead of ToString --- src/path.rs | 21 +++++++++++---------- src/setup.rs | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/path.rs b/src/path.rs index d9ce6a1..ad20053 100644 --- a/src/path.rs +++ b/src/path.rs @@ -1,4 +1,5 @@ use std::{ + fmt::Display, fs::read_dir, path::{Path, PathBuf}, }; @@ -40,11 +41,11 @@ impl File { } } -impl ToString for File { - fn to_string(&self) -> String { +impl Display for File { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::Image(image) => image.to_string(), - Self::Folder(folder) => folder.to_string(), + Self::Image(image) => write!(f, "{}", image), + Self::Folder(folder) => write!(f, "{}", folder), } } } @@ -192,9 +193,9 @@ impl ImagePath { } } -impl ToString for ImagePath { - fn to_string(&self) -> String { - self.path.to_str().unwrap().to_owned() +impl Display for ImagePath { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.path.to_str().unwrap()) } } @@ -228,9 +229,9 @@ impl AnimtaedFolder { } } -impl ToString for AnimtaedFolder { - fn to_string(&self) -> String { - self.path.to_str().unwrap().to_owned() +impl Display for AnimtaedFolder { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.path.to_str().unwrap()) } } diff --git a/src/setup.rs b/src/setup.rs index 35bcf52..91cca93 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -21,7 +21,7 @@ pub fn run(settings: Settings, action: Actions) { Err(err) => eprintln!("Error, {}", err), }, Actions::Get => match get_next_wallpaper(&settings) { - Ok(wallpaper) => println!("{}", wallpaper.to_string()), + Ok(wallpaper) => println!("{}", wallpaper), Err(err) => eprintln!("Error, {}", err), }, }