fn build_stats(activities: &[Activity], start: &Date<Local>, end: &Date<Local>) -> Vec<DayStats> {
    let mut by_day: HashMap<Date<Local>, DayStats> = HashMap::new();

    for activity in activities {
        let today = activity.timestamp.date();

        let stats = by_day.entry(today).or_insert_with(|| DayStats::new(&today));
        stats.add(&activity);
    }

    let mut results = Vec::new();
    let mut day = *start;
    while day <= *end {
        let stats = by_day.remove(&day).unwrap_or_else(|| DayStats::new(&day));
        results.push(stats);
        day = day.succ();
    }

    results
}
/// Build daily statistics for the given category
///
///  # Arguments
///  * `activities`: All recorded activities in the given interval
///  * `start`: Interval start date
///  * `end`: Interval end date
///
///  # Returns
///  A vector with one entry per day in (start..=end), each holding the total number of reps for
///  all categories
Build daily statistics for the given category
Build daily statistics for the given category
fn build_stats(activities: &[Activity], start: &Date<Local>, end: &Date<Local>) -> Vec<DayStats> {
    let mut by_day: HashMap<Date<Local>, DayStats> = HashMap::new();
    for activity in activities {
        let today = activity.timestamp.date();
        let stats = by_day.entry(today).or_insert_with(|| DayStats::new(&today));
        stats.add(&activity);
    }
    let mut results = Vec::new();
    let mut day = *start;
    while day <= *end {
        let stats = by_day.remove(&day).unwrap_or_else(|| DayStats::new(&day));
        results.push(stats);
        day = day.succ();
    }
    results
}
fn build_stats ( activities : & [ Activity ] , start : & Date < Local > , end : & Date < Local > ) -> Vec < DayStats > { let mut by_day : HashMap < Date < Local > , DayStats > = HashMap :: new ( ) ; for activity in activities { let today = activity . timestamp . date ( ) ; let stats = by_day . entry ( today ) . or_insert_with ( | | DayStats :: new ( & today ) ) ; stats . add ( & activity ) ; } let mut results = Vec :: new ( ) ; let mut day = * start ; while day <= * end { let stats = by_day . remove ( & day ) . unwrap_or_else ( | | DayStats :: new ( & day ) ) ; results . push ( stats ) ; day = day . succ ( ) ; } results }
Build daily statistics for the given category
Build daily statistics for the given category
A vector with one entry per day in (start..=end), each holding the total number of reps for
all categories
A vector with one entry per day in ( start .. = end ) each holding the total number of reps for all categories
activities
&[Activity]
start
&Date<Local>
end
&Date<Local>