pub fn parse<R: BufRead>(source: R) -> Result<Run> {
    let mut run = Run::new();

    run.set_game_name("Portal 2");
    run.set_category_name("Any%");

    let mut lines = source.lines();
    lines.next(); // Skip the header

    let mut aggregate_ticks = 0.0;

    let mut line = lines.next().context(ExpectedMap)?.context(ReadMap)?;
    for &(chapter_name, maps) in &CHAPTERS {
        for &map in maps {
            {
                let mut splits = line.split(',');
                let map_name = splits.next().context(ExpectedMapName)?;
                if map_name != map {
                    return Err(Error::ExpectedDifferentMapName {
                        expected: map,
                        found: map_name.into(),
                    });
                }
                let start_ticks: f64 = splits
                    .next()
                    .context(ExpectedStartTicks)?
                    .parse()
                    .context(ParseStartTicks)?;
                let end_ticks: f64 = splits
                    .next()
                    .context(ExpectedEndTicks)?
                    .parse()
                    .context(ParseEndTicks)?;
                let map_ticks = end_ticks - start_ticks;
                aggregate_ticks += map_ticks;
            }

            while let Some(Ok(next_line)) = lines.next() {
                line = next_line;
                let mut splits = line.split(',');
                if splits.next() == Some(map) {
                    let start_ticks: f64 = splits
                        .next()
                        .context(ExpectedStartTicks)?
                        .parse()
                        .context(ParseStartTicks)?;
                    let end_ticks: f64 = splits
                        .next()
                        .context(ExpectedEndTicks)?
                        .parse()
                        .context(ParseEndTicks)?;
                    let map_ticks = end_ticks - start_ticks;
                    aggregate_ticks += map_ticks;
                } else {
                    break;
                }
            }
        }

        let time = GameTime(Some(TimeSpan::from_seconds(aggregate_ticks / 60.0))).into();
        let mut segment = Segment::new(chapter_name);
        segment.set_personal_best_split_time(time);

        run.push_segment(segment);
    }

    Ok(run)
}
/// Attempts to parse a Portal 2 Live Timer splits file.
Attempts to parse a Portal 2 Live Timer splits file.
Attempts to parse a Portal 2 Live Timer splits file .
pub fn parse<R: BufRead>(source: R) -> Result<Run> {
    let mut run = Run::new();
    run.set_game_name("Portal 2");
    run.set_category_name("Any%");
    let mut lines = source.lines();
    lines.next(); // Skip the header
    let mut aggregate_ticks = 0.0;
    let mut line = lines.next().context(ExpectedMap)?.context(ReadMap)?;
    for &(chapter_name, maps) in &CHAPTERS {
        for &map in maps {
            {
                let mut splits = line.split(',');
                let map_name = splits.next().context(ExpectedMapName)?;
                if map_name != map {
                    return Err(Error::ExpectedDifferentMapName {
                        expected: map,
                        found: map_name.into(),
                    });
                }
                let start_ticks: f64 = splits
                    .next()
                    .context(ExpectedStartTicks)?
                    .parse()
                    .context(ParseStartTicks)?;
                let end_ticks: f64 = splits
                    .next()
                    .context(ExpectedEndTicks)?
                    .parse()
                    .context(ParseEndTicks)?;
                let map_ticks = end_ticks - start_ticks;
                aggregate_ticks += map_ticks;
            }
            while let Some(Ok(next_line)) = lines.next() {
                line = next_line;
                let mut splits = line.split(',');
                if splits.next() == Some(map) {
                    let start_ticks: f64 = splits
                        .next()
                        .context(ExpectedStartTicks)?
                        .parse()
                        .context(ParseStartTicks)?;
                    let end_ticks: f64 = splits
                        .next()
                        .context(ExpectedEndTicks)?
                        .parse()
                        .context(ParseEndTicks)?;
                    let map_ticks = end_ticks - start_ticks;
                    aggregate_ticks += map_ticks;
                } else {
                    break;
                }
            }
        }
        let time = GameTime(Some(TimeSpan::from_seconds(aggregate_ticks / 60.0))).into();
        let mut segment = Segment::new(chapter_name);
        segment.set_personal_best_split_time(time);
        run.push_segment(segment);
    }
    Ok(run)
}
pub fn parse < R : BufRead > ( source : R ) -> Result < Run > { let mut run = Run :: new ( ) ; run . set_game_name ( " " ) ; run . set_category_name ( " " ) ; let mut lines = source . lines ( ) ; lines . next ( ) ; // Skip the header let mut aggregate_ticks = 0.0 ; let mut line = lines . next ( ) . context ( ExpectedMap ) ? . context ( ReadMap ) ? ; for & ( chapter_name , maps ) in & CHAPTERS { for & map in maps { { let mut splits = line . split ( ',' ) ; let map_name = splits . next ( ) . context ( ExpectedMapName ) ? ; if map_name != map { return Err ( Error :: ExpectedDifferentMapName { expected : map , found : map_name . into ( ) , } ) ; } let start_ticks : f64 = splits . next ( ) . context ( ExpectedStartTicks ) ? . parse ( ) . context ( ParseStartTicks ) ? ; let end_ticks : f64 = splits . next ( ) . context ( ExpectedEndTicks ) ? . parse ( ) . context ( ParseEndTicks ) ? ; let map_ticks = end_ticks - start_ticks ; aggregate_ticks += map_ticks ; } while let Some ( Ok ( next_line ) ) = lines . next ( ) { line = next_line ; let mut splits = line . split ( ',' ) ; if splits . next ( ) == Some ( map ) { let start_ticks : f64 = splits . next ( ) . context ( ExpectedStartTicks ) ? . parse ( ) . context ( ParseStartTicks ) ? ; let end_ticks : f64 = splits . next ( ) . context ( ExpectedEndTicks ) ? . parse ( ) . context ( ParseEndTicks ) ? ; let map_ticks = end_ticks - start_ticks ; aggregate_ticks += map_ticks ; } else { break ; } } } let time = GameTime ( Some ( TimeSpan :: from_seconds ( aggregate_ticks / 60.0 ) ) ) . into ( ) ; let mut segment = Segment :: new ( chapter_name ) ; segment . set_personal_best_split_time ( time ) ; run . push_segment ( segment ) ; } Ok ( run ) }
Attempts to parse a Portal 2 Live Timer splits file.
Attempts to parse a Portal 2 Live Timer splits file .
source
R
source
R