pub fn to_yearly(&self) -> Yearly {
        let years_list = self.get_distinct_years();

        let mut to_return: Vec<YearlyItem> = Vec::new();
        years_list.iter().for_each(|year| {
            let folded = self.0.iter().filter(|daily| daily.year == *year).fold(
                YearlyItem {
                    year: *year,
                    positive: 0,
                    recovered: 0,
                    deaths: 0,
                    active: 0,
                },
                |mut acc, next| {
                    acc.positive += next.positive;
                    acc.recovered += next.recovered;
                    acc.deaths += next.deaths;
                    acc.active += next.active;
                    acc
                },
            );

            to_return.push(folded);
        });

        Yearly(to_return)
    }
/// Convert daily into yearly format.
///
/// #### Output
/// ```json
/// [
///     {
///         "year": 2020,
///         "positive": 743198,
///         "recovered": 611097,
///         "deaths": 22138,
///         "active": 109963
///     },
///     {
///         "year": 2021,
///         "positive": 3519522,
///         "recovered": 3503237,
///         "deaths": 121956,
///         "active": -105671
///     },
///     ...
/// ]
/// ```
Convert daily into yearly format.
Convert daily into yearly format .
pub fn to_yearly(&self) -> Yearly {
        let years_list = self.get_distinct_years();
        let mut to_return: Vec<YearlyItem> = Vec::new();
        years_list.iter().for_each(|year| {
            let folded = self.0.iter().filter(|daily| daily.year == *year).fold(
                YearlyItem {
                    year: *year,
                    positive: 0,
                    recovered: 0,
                    deaths: 0,
                    active: 0,
                },
                |mut acc, next| {
                    acc.positive += next.positive;
                    acc.recovered += next.recovered;
                    acc.deaths += next.deaths;
                    acc.active += next.active;
                    acc
                },
            );
            to_return.push(folded);
        });
        Yearly(to_return)
    }
pub fn to_yearly ( & self ) -> Yearly { let years_list = self . get_distinct_years ( ) ; let mut to_return : Vec < YearlyItem > = Vec :: new ( ) ; years_list . iter ( ) . for_each ( | year | { let folded = self . 0 . iter ( ) . filter ( | daily | daily . year == * year ) . fold ( YearlyItem { year : * year , positive : 0 , recovered : 0 , deaths : 0 , active : 0 , } , | mut acc , next | { acc . positive += next . positive ; acc . recovered += next . recovered ; acc . deaths += next . deaths ; acc . active += next . active ; acc } , ) ; to_return . push ( folded ) ; } ) ; Yearly ( to_return ) }
Convert daily into yearly format.
Convert daily into yearly format .
&self
output
None