pub(crate) fn determine_percentile(
    offset: TimeSpan,
    segments: &[Segment],
    method: TimingMethod,
    goal_time: Option<TimeSpan>,
    skill_curve: &mut SkillCurve,
) -> f64 {
    skill_curve.for_segments(segments, method);

    // Depending on whether we have a goal time or not, we use that goal time
    // or try to determine a personal best split time that we use for the goal
    // time. In that case we may need to limit the slice again to the last split
    // that actually has a split time we can work with.
    let goal_time = if let Some(goal_time) = goal_time {
        goal_time
    } else {
        let (new_len, goal_time) = segments[..skill_curve.len()]
            .iter()
            .enumerate()
            .rev()
            .find_map(|(i, s)| s.personal_best_split_time()[method].map(|t| (i + 1, t)))
            .unwrap_or_default();
        skill_curve.truncate(new_len);
        goal_time
    };

    skill_curve.find_percentile_for_time(offset, goal_time)
}
// FIXME: Possibly move this into the analysis module.
Possibly move this into the analysis module.
Possibly move this into the analysis module .
pub(crate) fn determine_percentile(
    offset: TimeSpan,
    segments: &[Segment],
    method: TimingMethod,
    goal_time: Option<TimeSpan>,
    skill_curve: &mut SkillCurve,
) -> f64 {
    skill_curve.for_segments(segments, method);
    // Depending on whether we have a goal time or not, we use that goal time
    // or try to determine a personal best split time that we use for the goal
    // time. In that case we may need to limit the slice again to the last split
    // that actually has a split time we can work with.
    let goal_time = if let Some(goal_time) = goal_time {
        goal_time
    } else {
        let (new_len, goal_time) = segments[..skill_curve.len()]
            .iter()
            .enumerate()
            .rev()
            .find_map(|(i, s)| s.personal_best_split_time()[method].map(|t| (i + 1, t)))
            .unwrap_or_default();
        skill_curve.truncate(new_len);
        goal_time
    };
    skill_curve.find_percentile_for_time(offset, goal_time)
}
pub ( crate ) fn determine_percentile ( offset : TimeSpan , segments : & [ Segment ] , method : TimingMethod , goal_time : Option < TimeSpan > , skill_curve : & mut SkillCurve , ) -> f64 { skill_curve . for_segments ( segments , method ) ; // Depending on whether we have a goal time or not, we use that goal time // or try to determine a personal best split time that we use for the goal // time. In that case we may need to limit the slice again to the last split // that actually has a split time we can work with. let goal_time = if let Some ( goal_time ) = goal_time { goal_time } else { let ( new_len , goal_time ) = segments [ .. skill_curve . len ( ) ] . iter ( ) . enumerate ( ) . rev ( ) . find_map ( | ( i , s ) | s . personal_best_split_time ( ) [ method ] . map ( | t | ( i + 1 , t ) ) ) . unwrap_or_default ( ) ; skill_curve . truncate ( new_len ) ; goal_time } ; skill_curve . find_percentile_for_time ( offset , goal_time ) }
FIXME: Possibly move this into the analysis module.
FIXME : Possibly move this into the analysis module .
offset
TimeSpan
segments
&[Segment]
method
TimingMethod
goal_time
Option<TimeSpan>
skill_curve
&mut SkillCurve
offset
TimeSpan
segments
&[Segment]
method
TimingMethod
goal_time
Option<TimeSpan>
skill_curve
&mut SkillCurve