From d980e1055087c1627394eaeb6251d2723a7d51c8 Mon Sep 17 00:00:00 2001 From: Lukas Pustina Date: Sat, 11 Jan 2020 17:23:16 +0100 Subject: [PATCH] Add impl for std traits --- src/command.rs | 6 +++--- src/config.rs | 8 ++++---- src/renderer.rs | 3 ++- src/runner.rs | 5 +---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/command.rs b/src/command.rs index 823f5ec..47f3544 100644 --- a/src/command.rs +++ b/src/command.rs @@ -37,7 +37,7 @@ use subprocess::{Popen, PopenConfig, Redirection}; /// } => println!("Command errored because {}", reason), /// }; /// ``` -#[derive(Debug, Deserialize, PartialEq, Serialize, Clone)] +#[derive(Debug, Deserialize, PartialEq, Eq, Serialize, Clone)] pub struct Command { pub(crate) name: String, pub(crate) title: Option, @@ -177,7 +177,7 @@ impl Command { } } -#[derive(Debug, Deserialize, PartialEq, Serialize, Clone)] +#[derive(Debug, PartialEq, Eq, Deserialize, Serialize, Clone)] pub struct Link { pub(crate) name: String, pub(crate) url: String, @@ -197,7 +197,7 @@ impl Link { } /// Encapsulates a command execution result -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Eq, Deserialize, Serialize, Clone)] pub enum CommandResult { /// `Command` has been executed successfully and `String` contains stdout. Success { diff --git a/src/config.rs b/src/config.rs index f4cac1e..048fbc6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -29,7 +29,7 @@ pub enum Error { /// Result type pub type Result = std::result::Result; -#[derive(Debug, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)] pub struct Config { pub defaults: Defaults, pub hostinfo: Option, @@ -166,7 +166,7 @@ impl Config { } } -#[derive(Debug, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)] pub struct Defaults { #[serde(default = "default_profile")] pub profile: String, @@ -197,12 +197,12 @@ fn default_repetitions() -> usize { Defaults::default().repetitions } fn default_max_parallel_commands() -> usize { Defaults::default().max_parallel_commands } -#[derive(Debug, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)] pub struct Hostinfo { pub commands: Vec, } -#[derive(Debug, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)] pub struct Profile { pub name: String, pub commands: Vec, diff --git a/src/renderer.rs b/src/renderer.rs index 3e32b5b..c1cef34 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -33,7 +33,7 @@ pub use json::JsonRenderer; pub mod json { use super::*; - #[derive(Default)] + #[derive(Default, Debug, Eq, PartialEq, Clone)] pub struct JsonRenderer {} impl JsonRenderer { @@ -53,6 +53,7 @@ pub mod handlebars { use ::handlebars::Handlebars; use std::{fs::File, io::Read, path::Path}; + #[derive(Default, Debug, Eq, PartialEq, Clone)] pub struct HbsRenderer { template: String, } diff --git a/src/runner.rs b/src/runner.rs index c3d3603..a9784f2 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -32,6 +32,7 @@ pub mod thread { thread::JoinHandle, }; + #[derive(Default, Debug, Clone)] pub struct ThreadRunner { progress_tx: Option>, } @@ -121,10 +122,6 @@ pub mod thread { } } - impl Default for ThreadRunner { - fn default() -> Self { ThreadRunner { progress_tx: None } } - } - #[cfg(test)] mod tests { use super::*;