2018-06-03 18:04:58 +03:00
|
|
|
use std::borrow::Cow;
|
|
|
|
|
|
2018-06-27 18:06:24 +03:00
|
|
|
type CowString<'a> = Cow<'a, str>;
|
2018-08-24 21:52:17 +03:00
|
|
|
pub struct Report<'a> {
|
|
|
|
|
data: Vec<(CowString<'a>, bool)>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'a> Report<'a> {
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self { data: Vec::new() }
|
|
|
|
|
}
|
2018-06-03 18:04:58 +03:00
|
|
|
|
2018-08-24 21:52:17 +03:00
|
|
|
pub fn push_result<M>(&mut self, result: Option<(M, bool)>)
|
|
|
|
|
where
|
|
|
|
|
M: Into<CowString<'a>>,
|
|
|
|
|
{
|
|
|
|
|
if let Some((key, success)) = result {
|
|
|
|
|
let key = key.into();
|
|
|
|
|
|
|
|
|
|
debug_assert!(!self.data.iter().any(|(k, _)| k == &key), "{} already reported", key);
|
|
|
|
|
self.data.push((key, success));
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-06 15:32:38 +03:00
|
|
|
|
2018-08-24 21:52:17 +03:00
|
|
|
pub fn data(&self) -> &Vec<(CowString<'a>, bool)> {
|
|
|
|
|
&self.data
|
2018-06-06 15:32:38 +03:00
|
|
|
}
|
|
|
|
|
}
|