fn compute_page_row_intervals(
    locations: &[PageLocation],
    num_rows: usize,
) -> Result<Vec<Interval>, Error> {
    if locations.is_empty() {
        return Ok(vec![]);
    };

    let last = (|| {
        let start: usize = locations.last().unwrap().first_row_index.try_into()?;
        let length = num_rows - start;
        Result::<_, Error>::Ok(Interval::new(start, length))
    })();

    let pages_lengths = locations
        .windows(2)
        .map(|x| {
            let start = usize::try_from(x[0].first_row_index)?;
            let length = usize::try_from(x[1].first_row_index - x[0].first_row_index)?;
            Ok(Interval::new(start, length))
        })
        .chain(std::iter::once(last));
    pages_lengths.collect()
}
/// Returns the set of (row) intervals of the pages.
Returns the set of (row) intervals of the pages.
Returns the set of ( row ) intervals of the pages .
fn compute_page_row_intervals(
    locations: &[PageLocation],
    num_rows: usize,
) -> Result<Vec<Interval>, Error> {
    if locations.is_empty() {
        return Ok(vec![]);
    };
    let last = (|| {
        let start: usize = locations.last().unwrap().first_row_index.try_into()?;
        let length = num_rows - start;
        Result::<_, Error>::Ok(Interval::new(start, length))
    })();
    let pages_lengths = locations
        .windows(2)
        .map(|x| {
            let start = usize::try_from(x[0].first_row_index)?;
            let length = usize::try_from(x[1].first_row_index - x[0].first_row_index)?;
            Ok(Interval::new(start, length))
        })
        .chain(std::iter::once(last));
    pages_lengths.collect()
}
fn compute_page_row_intervals ( locations : & [ PageLocation ] , num_rows : usize , ) -> Result < Vec < Interval > , Error > { if locations . is_empty ( ) { return Ok ( vec ! [ ] ) ; } ; let last = ( | | { let start : usize = locations . last ( ) . unwrap ( ) . first_row_index . try_into ( ) ? ; let length = num_rows - start ; Result :: < _ , Error > :: Ok ( Interval :: new ( start , length ) ) } ) ( ) ; let pages_lengths = locations . windows ( 2 ) . map ( | x | { let start = usize :: try_from ( x [ 0 ] . first_row_index ) ? ; let length = usize :: try_from ( x [ 1 ] . first_row_index - x [ 0 ] . first_row_index ) ? ; Ok ( Interval :: new ( start , length ) ) } ) . chain ( std :: iter :: once ( last ) ) ; pages_lengths . collect ( ) }
Returns the set of (row) intervals of the pages.
Returns the set of ( row ) intervals of the pages .
locations
&[PageLocation]
num_rows
usize