From 7b6fe948428e568a24257ed11774ade75edd7c63 Mon Sep 17 00:00:00 2001 From: Lukas Pustina Date: Sun, 12 Jan 2020 14:46:46 +0100 Subject: [PATCH] Clippy and fmt --- src/analysis.rs | 60 +++++++++++++++++--------------------------- src/bin/usereport.rs | 2 +- src/config.rs | 8 ++++-- src/renderer.rs | 3 +-- 4 files changed, 31 insertions(+), 42 deletions(-) diff --git a/src/analysis.rs b/src/analysis.rs index f1f5e69..449ad62 100644 --- a/src/analysis.rs +++ b/src/analysis.rs @@ -3,8 +3,8 @@ use crate::{runner, Command, CommandResult, Runner}; use chrono::{DateTime, Local}; use serde::Serialize; use snafu::{ResultExt, Snafu}; -use uname; use std::fmt::Debug; +use uname; /// Error type #[derive(Debug, Snafu)] @@ -23,15 +23,15 @@ pub type Result = std::result::Result; // Copy: This allows to reuse the into_iter object; safe for &Vec or &[] #[derive(Debug)] -pub struct Analysis<'a, I: IntoIterator + Copy> { - runner: Box>, - hostinfos: I, - commands: I, - repetitions: usize, +pub struct Analysis<'a, I: IntoIterator + Copy> { + runner: Box>, + hostinfos: I, + commands: I, + repetitions: usize, max_parallel_commands: usize, } -impl<'a, I: IntoIterator + Copy> Analysis<'a, I> { +impl<'a, I: IntoIterator + Copy> Analysis<'a, I> { pub fn new(runner: Box>, hostinfos: I, commands: I) -> Self { Analysis { hostinfos, @@ -96,12 +96,12 @@ impl<'a, I: IntoIterator + Copy> Analysis<'a, I> { #[derive(Debug, Serialize)] pub struct AnalysisReport { - pub(crate) hostname: String, - pub(crate) uname: String, - pub(crate) date_time: DateTime, - pub(crate) hostinfo_results: Vec, - pub(crate) command_results: Vec>, - pub(crate) repetitions: usize, + pub(crate) hostname: String, + pub(crate) uname: String, + pub(crate) date_time: DateTime, + pub(crate) hostinfo_results: Vec, + pub(crate) command_results: Vec>, + pub(crate) repetitions: usize, pub(crate) max_parallel_commands: usize, } @@ -114,7 +114,7 @@ impl AnalysisReport { command_results: Vec>, repetitions: usize, max_parallel_commands: usize, - ) -> AnalysisReport{ + ) -> AnalysisReport { AnalysisReport { hostname: hostname.into(), uname: uname.into(), @@ -122,37 +122,23 @@ impl AnalysisReport { hostinfo_results, command_results, repetitions, - max_parallel_commands + max_parallel_commands, } } - pub fn hostname(&self) -> &str { - &self.hostname - } + pub fn hostname(&self) -> &str { &self.hostname } - pub fn uname(&self) -> &str { - &self.uname - } + pub fn uname(&self) -> &str { &self.uname } - pub fn date_time(&self) -> &DateTime { - &self.date_time - } + pub fn date_time(&self) -> &DateTime { &self.date_time } - pub fn hostinfo_results(&self) -> &[CommandResult] { - &self.hostinfo_results - } + pub fn hostinfo_results(&self) -> &[CommandResult] { &self.hostinfo_results } - pub fn command_results(&self) -> &[Vec] { - &self.command_results - } + pub fn command_results(&self) -> &[Vec] { &self.command_results } - pub fn repetitions(&self) -> usize { - self.repetitions - } + pub fn repetitions(&self) -> usize { self.repetitions } - pub fn max_parallel_commands(&self) -> usize { - self.max_parallel_commands - } + pub fn max_parallel_commands(&self) -> usize { self.max_parallel_commands } } #[cfg(test)] @@ -180,7 +166,7 @@ mod tests { #[derive(Debug)] struct MyRunner {}; - impl<'a, I: IntoIterator> Runner<'a, I> for MyRunner { + impl<'a, I: IntoIterator> Runner<'a, I> for MyRunner { fn run(&self, _commands: I, _max_parallel_commands: usize) -> runner::Result> { Ok(Vec::new()) } diff --git a/src/bin/usereport.rs b/src/bin/usereport.rs index 3e7733c..12e55d1 100644 --- a/src/bin/usereport.rs +++ b/src/bin/usereport.rs @@ -1,6 +1,6 @@ use exitfailure::ExitFailure; use failure::{format_err, ResultExt}; -use indicatif::{ProgressBar, ProgressStyle, ProgressDrawTarget}; +use indicatif::{ProgressBar, ProgressDrawTarget, ProgressStyle}; use prettytable::{cell, format, row, Cell, Row, Table}; use std::{ io::Write, diff --git a/src/config.rs b/src/config.rs index 9cfdad5..e90ea64 100644 --- a/src/config.rs +++ b/src/config.rs @@ -214,9 +214,13 @@ impl Profile { Self::new_with_description(name, commands, None) } - pub fn new_with_description + Clone, S: Into>>(name: T, commands: &[T], description: S) -> Profile { + pub fn new_with_description + Clone, S: Into>>( + name: T, + commands: &[T], + description: S, + ) -> Profile { let name = name.into(); - let commands = commands.clone().to_vec().into_iter().map(Into::into).collect(); + let commands = commands.to_vec().into_iter().map(Into::into).collect(); let description = description.into().map(Into::into); Profile { diff --git a/src/renderer.rs b/src/renderer.rs index ef6cd1c..e39eb95 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -1,8 +1,7 @@ use crate::analysis::AnalysisReport; use snafu::{ResultExt, Snafu}; -use std::fmt::Debug; -use std::{io::Write, path::PathBuf}; +use std::{fmt::Debug, io::Write, path::PathBuf}; /// Error type #[derive(Debug, Snafu)]