use std::marker::PhantomData; use gix_features::parallel; use super::Outcome; use crate::data::output; pub struct Statistics { total: Outcome, counts: Vec, _err: PhantomData, } impl Statistics { pub fn new() -> Self { Statistics { total: Default::default(), counts: Default::default(), _err: PhantomData, } } } impl parallel::Reduce for Statistics { type Input = Result<(Vec, Outcome), E>; type FeedProduce = (); type Output = (Vec, Outcome); type Error = E; fn feed(&mut self, item: Self::Input) -> Result { let (counts, stats) = item?; self.total.aggregate(stats); self.counts.extend(counts); Ok(()) } fn finalize(self) -> Result { Ok((self.counts, self.total)) } }