Add summary

This commit is contained in:
Roey Darwish Dror
2018-06-03 18:04:58 +03:00
parent d473b288b3
commit 239ad6e4f3
5 changed files with 108 additions and 20 deletions

21
src/report.rs Normal file
View File

@@ -0,0 +1,21 @@
use std::borrow::Cow;
use std::collections::HashMap;
use std::process::ExitStatus;
pub type Report = HashMap<String, bool>;
pub trait Reporter {
fn report<'a, M: Into<Cow<'a, str>>>(&self, key: M, report: &mut Report);
}
impl Reporter for ExitStatus {
fn report<'a, M: Into<Cow<'a, str>>>(&self, key: M, report: &mut Report) {
report.insert(key.into().into_owned(), self.success());
}
}
impl Reporter for bool {
fn report<'a, M: Into<Cow<'a, str>>>(&self, key: M, report: &mut Report) {
report.insert(key.into().into_owned(), *self);
}
}