pub fn import_comparison<S: Into<String>>(
        &mut self,
        run: &Run,
        comparison: S,
    ) -> ComparisonResult<()> {
        let comparison = comparison.into();
        self.run.add_custom_comparison(comparison.as_str())?;

        let mut remaining_segments = self.run.segments_mut().as_mut_slice();

        for segment in run.segments().iter().take(run.len().saturating_sub(1)) {
            if let Some((segment_index, my_segment)) = remaining_segments
                .iter_mut()
                .enumerate()
                .find(|(_, s)| unicase::eq(segment.name(), s.name()))
            {
                *my_segment.comparison_mut(&comparison) = segment.personal_best_split_time();
                remaining_segments = &mut remaining_segments[segment_index + 1..];
            }
        }

        if let (Some(my_segment), Some(segment)) =
            (self.run.segments_mut().last_mut(), run.segments().last())
        {
            *my_segment.comparison_mut(&comparison) = segment.personal_best_split_time();
        }

        self.fix();
        Ok(())
    }
/// Imports the Personal Best from the provided run as a comparison. The
/// comparison can't be added if its name starts with `[Race]` or it already
/// exists.
Imports the Personal Best from the provided run as a comparison. The
comparison can't be added if its name starts with `[Race]` or it already
exists.
Imports the Personal Best from the provided run as a comparison . The comparison can ' t be added if its name starts with ` [ Race ] ` or it already exists .
pub fn import_comparison<S: Into<String>>(
        &mut self,
        run: &Run,
        comparison: S,
    ) -> ComparisonResult<()> {
        let comparison = comparison.into();
        self.run.add_custom_comparison(comparison.as_str())?;
        let mut remaining_segments = self.run.segments_mut().as_mut_slice();
        for segment in run.segments().iter().take(run.len().saturating_sub(1)) {
            if let Some((segment_index, my_segment)) = remaining_segments
                .iter_mut()
                .enumerate()
                .find(|(_, s)| unicase::eq(segment.name(), s.name()))
            {
                *my_segment.comparison_mut(&comparison) = segment.personal_best_split_time();
                remaining_segments = &mut remaining_segments[segment_index + 1..];
            }
        }
        if let (Some(my_segment), Some(segment)) =
            (self.run.segments_mut().last_mut(), run.segments().last())
        {
            *my_segment.comparison_mut(&comparison) = segment.personal_best_split_time();
        }
        self.fix();
        Ok(())
    }
pub fn import_comparison < S : Into < String > > ( & mut self , run : & Run , comparison : S , ) -> ComparisonResult < ( ) > { let comparison = comparison . into ( ) ; self . run . add_custom_comparison ( comparison . as_str ( ) ) ? ; let mut remaining_segments = self . run . segments_mut ( ) . as_mut_slice ( ) ; for segment in run . segments ( ) . iter ( ) . take ( run . len ( ) . saturating_sub ( 1 ) ) { if let Some ( ( segment_index , my_segment ) ) = remaining_segments . iter_mut ( ) . enumerate ( ) . find ( | ( _ , s ) | unicase :: eq ( segment . name ( ) , s . name ( ) ) ) { * my_segment . comparison_mut ( & comparison ) = segment . personal_best_split_time ( ) ; remaining_segments = & mut remaining_segments [ segment_index + 1 .. ] ; } } if let ( Some ( my_segment ) , Some ( segment ) ) = ( self . run . segments_mut ( ) . last_mut ( ) , run . segments ( ) . last ( ) ) { * my_segment . comparison_mut ( & comparison ) = segment . personal_best_split_time ( ) ; } self . fix ( ) ; Ok ( ( ) ) }
Imports the Personal Best from the provided run as a comparison.
Imports the Personal Best from the provided run as a comparison .
&mut self
run
&Run
comparison
S
&mut self
run
&Run
comparison
S