fn match_preceding_blanks(
    line_nums: &[(Option<LineNumber>, Option<LineNumber>)],
    lhs_lines: &[&str],
    rhs_lines: &[&str],
) -> Vec<(Option<LineNumber>, Option<LineNumber>)> {
    let mut prev_lhs = None;
    let mut prev_rhs = None;

    let mut res: Vec<(Option<LineNumber>, Option<LineNumber>)> = vec![];
    for (lhs_line_num, rhs_line_num) in line_nums {
        match (lhs_line_num, rhs_line_num, prev_lhs, prev_rhs) {
            (Some(lhs_line_num), Some(rhs_line_num), None, None) => {
                // The first pair.
                res.append(&mut match_blanks_before(
                    (*lhs_line_num, *rhs_line_num),
                    lhs_lines,
                    rhs_lines,
                ));
            }
            (Some(lhs_line_num), Some(rhs_line_num), Some(prev_lhs), Some(prev_rhs)) => {
                // Later pairs.
                res.append(&mut match_blanks_between(
                    (*lhs_line_num, *rhs_line_num),
                    (prev_lhs, prev_rhs),
                    lhs_lines,
                    rhs_lines,
                ));
            }
            _ => {}
        }

        res.push((*lhs_line_num, *rhs_line_num));

        if lhs_line_num.is_some() {
            prev_lhs = *lhs_line_num;
        }
        if rhs_line_num.is_some() {
            prev_rhs = *rhs_line_num;
        }
    }

    res
}
/// For every line number pair, if there are blank lines preceding the
/// pair, add those blank lines to the vec.
///
/// This substantially improves alignment, leading to more readable
/// diffs.
///
/// We don't need to match blank lines following each pair. After
/// matching up all the matching lines, we just display the remaining
/// lines side-by-side regardless of content (see
/// `ensure_contiguous`). If there are blank lines immediately
/// following the pair, they will get aligned by this.
For every line number pair, if there are blank lines preceding the
pair, add those blank lines to the vec.

This substantially improves alignment, leading to more readable
diffs.

We don't need to match blank lines following each pair. After
matching up all the matching lines, we just display the remaining
lines side-by-side regardless of content (see
`ensure_contiguous`). If there are blank lines immediately
following the pair, they will get aligned by this.
For every line number pair if there are blank lines preceding the pair add those blank lines to the vec . This substantially improves alignment leading to more readable diffs . We don ' t need to match blank lines following each pair . After matching up all the matching lines we just display the remaining lines side - by - side regardless of content ( see ` ensure_contiguous ` ) . If there are blank lines immediately following the pair they will get aligned by this .
fn match_preceding_blanks(
    line_nums: &[(Option<LineNumber>, Option<LineNumber>)],
    lhs_lines: &[&str],
    rhs_lines: &[&str],
) -> Vec<(Option<LineNumber>, Option<LineNumber>)> {
    let mut prev_lhs = None;
    let mut prev_rhs = None;
    let mut res: Vec<(Option<LineNumber>, Option<LineNumber>)> = vec![];
    for (lhs_line_num, rhs_line_num) in line_nums {
        match (lhs_line_num, rhs_line_num, prev_lhs, prev_rhs) {
            (Some(lhs_line_num), Some(rhs_line_num), None, None) => {
                // The first pair.
                res.append(&mut match_blanks_before(
                    (*lhs_line_num, *rhs_line_num),
                    lhs_lines,
                    rhs_lines,
                ));
            }
            (Some(lhs_line_num), Some(rhs_line_num), Some(prev_lhs), Some(prev_rhs)) => {
                // Later pairs.
                res.append(&mut match_blanks_between(
                    (*lhs_line_num, *rhs_line_num),
                    (prev_lhs, prev_rhs),
                    lhs_lines,
                    rhs_lines,
                ));
            }
            _ => {}
        }
        res.push((*lhs_line_num, *rhs_line_num));
        if lhs_line_num.is_some() {
            prev_lhs = *lhs_line_num;
        }
        if rhs_line_num.is_some() {
            prev_rhs = *rhs_line_num;
        }
    }
    res
}
fn match_preceding_blanks ( line_nums : & [ ( Option < LineNumber > , Option < LineNumber > ) ] , lhs_lines : & [ & str ] , rhs_lines : & [ & str ] , ) -> Vec < ( Option < LineNumber > , Option < LineNumber > ) > { let mut prev_lhs = None ; let mut prev_rhs = None ; let mut res : Vec < ( Option < LineNumber > , Option < LineNumber > ) > = vec ! [ ] ; for ( lhs_line_num , rhs_line_num ) in line_nums { match ( lhs_line_num , rhs_line_num , prev_lhs , prev_rhs ) { ( Some ( lhs_line_num ) , Some ( rhs_line_num ) , None , None ) => { // The first pair. res . append ( & mut match_blanks_before ( ( * lhs_line_num , * rhs_line_num ) , lhs_lines , rhs_lines , ) ) ; } ( Some ( lhs_line_num ) , Some ( rhs_line_num ) , Some ( prev_lhs ) , Some ( prev_rhs ) ) => { // Later pairs. res . append ( & mut match_blanks_between ( ( * lhs_line_num , * rhs_line_num ) , ( prev_lhs , prev_rhs ) , lhs_lines , rhs_lines , ) ) ; } _ => { } } res . push ( ( * lhs_line_num , * rhs_line_num ) ) ; if lhs_line_num . is_some ( ) { prev_lhs = * lhs_line_num ; } if rhs_line_num . is_some ( ) { prev_rhs = * rhs_line_num ; } } res }
For every line number pair, if there are blank lines preceding the
pair, add those blank lines to the vec.
For every line number pair if there are blank lines preceding the pair add those blank lines to the vec .
line_nums
&[(Option<LineNumber>, Option<LineNumber>)]
lhs_lines
&[&str]
rhs_lines
&[&str]