tktax-histogram 0.2.2

A Rust crate that provides robust monthly histogram utilities for financial transactions, using specialized types from the TKTAX ecosystem.
Documentation
// ---------------- [ File: tktax-histogram/src/histogram.rs ]
crate::ix!();

#[derive(Getters,Debug)]
#[getset(get="pub")]
pub struct AccountHistogram {
    strategy: HistogramDisplayStrategy,
    months:   Vec<HistogramMonth>,
}

impl AccountHistogram {

    pub fn new(strategy: &HistogramDisplayStrategy) -> Self {
        Self {
            strategy: strategy.clone(),
            months:   vec![],
        }
    }

    pub fn push(&mut self, histogram_month: HistogramMonth) {
        self.months.push(histogram_month);
    }
}

impl fmt::Display for AccountHistogram {

    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

        for month in &self.months {

            month.fmt_with(f, &self.strategy)?;

            if month != self.months.last().unwrap() {

                writeln!(f, "________________________________")?;

            } else {

                // Add an empty line for better readability
                writeln!(f, " ")?;
            }
        }

        write!(f, "")
    }
}