fn merge_novel<'a>(
    lines: &[(TextChangeKind, Vec<&'a str>, Vec<&'a str>)],
) -> Vec<(TextChangeKind, Vec<&'a str>, Vec<&'a str>)> {
    let mut lhs_novel = vec![];
    let mut rhs_novel = vec![];

    let mut res: Vec<(TextChangeKind, Vec<_>, Vec<_>)> = vec![];
    for (kind, lhs_lines, rhs_lines) in lines {
        match kind {
            TextChangeKind::Novel => {
                lhs_novel.extend(lhs_lines.iter().copied());
                rhs_novel.extend(rhs_lines.iter().copied());
            }
            TextChangeKind::Unchanged => {
                if !lhs_novel.is_empty() || !rhs_novel.is_empty() {
                    res.push((TextChangeKind::Novel, lhs_novel, rhs_novel));
                    lhs_novel = vec![];
                    rhs_novel = vec![];
                }

                res.push((
                    TextChangeKind::Unchanged,
                    lhs_lines.clone(),
                    rhs_lines.clone(),
                ));
            }
        }
    }

    if !lhs_novel.is_empty() || !rhs_novel.is_empty() {
        res.push((TextChangeKind::Novel, lhs_novel, rhs_novel));
    }
    res
}
/// Merge contiguous sequences marked as novel.
Merge contiguous sequences marked as novel.
Merge contiguous sequences marked as novel .
fn merge_novel<'a>(
    lines: &[(TextChangeKind, Vec<&'a str>, Vec<&'a str>)],
) -> Vec<(TextChangeKind, Vec<&'a str>, Vec<&'a str>)> {
    let mut lhs_novel = vec![];
    let mut rhs_novel = vec![];
    let mut res: Vec<(TextChangeKind, Vec<_>, Vec<_>)> = vec![];
    for (kind, lhs_lines, rhs_lines) in lines {
        match kind {
            TextChangeKind::Novel => {
                lhs_novel.extend(lhs_lines.iter().copied());
                rhs_novel.extend(rhs_lines.iter().copied());
            }
            TextChangeKind::Unchanged => {
                if !lhs_novel.is_empty() || !rhs_novel.is_empty() {
                    res.push((TextChangeKind::Novel, lhs_novel, rhs_novel));
                    lhs_novel = vec![];
                    rhs_novel = vec![];
                }
                res.push((
                    TextChangeKind::Unchanged,
                    lhs_lines.clone(),
                    rhs_lines.clone(),
                ));
            }
        }
    }
    if !lhs_novel.is_empty() || !rhs_novel.is_empty() {
        res.push((TextChangeKind::Novel, lhs_novel, rhs_novel));
    }
    res
}
fn merge_novel < ' a > ( lines : & [ ( TextChangeKind , Vec < & ' a str > , Vec < & ' a str > ) ] , ) -> Vec < ( TextChangeKind , Vec < & ' a str > , Vec < & ' a str > ) > { let mut lhs_novel = vec ! [ ] ; let mut rhs_novel = vec ! [ ] ; let mut res : Vec < ( TextChangeKind , Vec < _ > , Vec < _ > ) > = vec ! [ ] ; for ( kind , lhs_lines , rhs_lines ) in lines { match kind { TextChangeKind :: Novel => { lhs_novel . extend ( lhs_lines . iter ( ) . copied ( ) ) ; rhs_novel . extend ( rhs_lines . iter ( ) . copied ( ) ) ; } TextChangeKind :: Unchanged => { if ! lhs_novel . is_empty ( ) || ! rhs_novel . is_empty ( ) { res . push ( ( TextChangeKind :: Novel , lhs_novel , rhs_novel ) ) ; lhs_novel = vec ! [ ] ; rhs_novel = vec ! [ ] ; } res . push ( ( TextChangeKind :: Unchanged , lhs_lines . clone ( ) , rhs_lines . clone ( ) , ) ) ; } } } if ! lhs_novel . is_empty ( ) || ! rhs_novel . is_empty ( ) { res . push ( ( TextChangeKind :: Novel , lhs_novel , rhs_novel ) ) ; } res }
Merge contiguous sequences marked as novel.
Merge contiguous sequences marked as novel .
lines
&[(TextChangeKind, Vec<&'a str>, Vec<&'a str>)]