Skip to content

Commit

Permalink
Clippy and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspustina committed Jan 12, 2020
1 parent 10c612f commit 7b6fe94
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 42 deletions.
60 changes: 23 additions & 37 deletions src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -23,15 +23,15 @@ pub type Result<T, E = Error> = std::result::Result<T, E>;

// Copy: This allows to reuse the into_iter object; safe for &Vec or &[]
#[derive(Debug)]
pub struct Analysis<'a, I: IntoIterator<Item=&'a Command> + Copy> {
runner: Box<dyn Runner<'a, I>>,
hostinfos: I,
commands: I,
repetitions: usize,
pub struct Analysis<'a, I: IntoIterator<Item = &'a Command> + Copy> {
runner: Box<dyn Runner<'a, I>>,
hostinfos: I,
commands: I,
repetitions: usize,
max_parallel_commands: usize,
}

impl<'a, I: IntoIterator<Item=&'a Command> + Copy> Analysis<'a, I> {
impl<'a, I: IntoIterator<Item = &'a Command> + Copy> Analysis<'a, I> {
pub fn new(runner: Box<dyn Runner<'a, I>>, hostinfos: I, commands: I) -> Self {
Analysis {
hostinfos,
Expand Down Expand Up @@ -96,12 +96,12 @@ impl<'a, I: IntoIterator<Item=&'a Command> + Copy> Analysis<'a, I> {

#[derive(Debug, Serialize)]
pub struct AnalysisReport {
pub(crate) hostname: String,
pub(crate) uname: String,
pub(crate) date_time: DateTime<Local>,
pub(crate) hostinfo_results: Vec<CommandResult>,
pub(crate) command_results: Vec<Vec<CommandResult>>,
pub(crate) repetitions: usize,
pub(crate) hostname: String,
pub(crate) uname: String,
pub(crate) date_time: DateTime<Local>,
pub(crate) hostinfo_results: Vec<CommandResult>,
pub(crate) command_results: Vec<Vec<CommandResult>>,
pub(crate) repetitions: usize,
pub(crate) max_parallel_commands: usize,
}

Expand All @@ -114,45 +114,31 @@ impl AnalysisReport {
command_results: Vec<Vec<CommandResult>>,
repetitions: usize,
max_parallel_commands: usize,
) -> AnalysisReport{
) -> AnalysisReport {
AnalysisReport {
hostname: hostname.into(),
uname: uname.into(),
date_time,
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<Local> {
&self.date_time
}
pub fn date_time(&self) -> &DateTime<Local> { &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<CommandResult>] {
&self.command_results
}
pub fn command_results(&self) -> &[Vec<CommandResult>] { &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)]
Expand Down Expand Up @@ -180,7 +166,7 @@ mod tests {
#[derive(Debug)]
struct MyRunner {};

impl<'a, I: IntoIterator<Item=&'a Command>> Runner<'a, I> for MyRunner {
impl<'a, I: IntoIterator<Item = &'a Command>> Runner<'a, I> for MyRunner {
fn run(&self, _commands: I, _max_parallel_commands: usize) -> runner::Result<Vec<CommandResult>> {
Ok(Vec::new())
}
Expand Down
2 changes: 1 addition & 1 deletion src/bin/usereport.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
8 changes: 6 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,13 @@ impl Profile {
Self::new_with_description(name, commands, None)
}

pub fn new_with_description<T: Into<String> + Clone, S: Into<Option<T>>>(name: T, commands: &[T], description: S) -> Profile {
pub fn new_with_description<T: Into<String> + Clone, S: Into<Option<T>>>(
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 {
Expand Down
3 changes: 1 addition & 2 deletions src/renderer.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down

0 comments on commit 7b6fe94

Please sign in to comment.