pub fn weighted_total(activities: &[Activity], categories: &CategoryLookup) -> u32 {
    let mut total = 0;

    for activity in activities {
        let cat = &activity.category;
        if let Some(category) = categories.find(cat) {
            total += ((activity.reps as f64) * category.weight) as u32;
        } else {
            // default to a weight of 1 (e.g. for categories that don't exist anymore)
            total += activity.reps;
        }
    }

    total
}
/// Calculate the weighted total repetitions over the the given activities
Calculate the weighted total repetitions over the the given activities
Calculate the weighted total repetitions over the the given activities
pub fn weighted_total(activities: &[Activity], categories: &CategoryLookup) -> u32 {
    let mut total = 0;
    for activity in activities {
        let cat = &activity.category;
        if let Some(category) = categories.find(cat) {
            total += ((activity.reps as f64) * category.weight) as u32;
        } else {
            // default to a weight of 1 (e.g. for categories that don't exist anymore)
            total += activity.reps;
        }
    }
    total
}
pub fn weighted_total ( activities : & [ Activity ] , categories : & CategoryLookup ) -> u32 { let mut total = 0 ; for activity in activities { let cat = & activity . category ; if let Some ( category ) = categories . find ( cat ) { total += ( ( activity . reps as f64 ) * category . weight ) as u32 ; } else { // default to a weight of 1 (e.g. for categories that don't exist anymore) total += activity . reps ; } } total }
Calculate the weighted total repetitions over the the given activities
Calculate the weighted total repetitions over the the given activities
activities
&[Activity]
categories
&CategoryLookup