fn diff_impl<'elem, T: Eq + Debug + 'elem>(
        res: &mut Vec<EditType<&'elem T>>,
        old: &'elem [T],
        mut old_range: Range<usize>,
        new: &'elem [T],
        mut new_range: Range<usize>,
        frontiers: &mut MyersFrontiers,
    ) {
        // Initial optimizations: we can skip the common prefix + suffix
        let common_pref_len = common_prefix_len(old, old_range.clone(), new, new_range.clone());
        old_range.start += common_pref_len;
        new_range.start += common_pref_len;

        let common_suf_len = common_suffix_len(old, old_range.clone(), new, new_range.clone());
        // Need to make sure our begin/end ranges don't overlap
        old_range.end = old_range.start.max(old_range.end - common_suf_len);
        new_range.end = new_range.start.max(new_range.end - common_suf_len);

        // We know if either or both of the inputs are empty, we don't have to bother finding the
        // middle snake
        if old_range.is_empty() && new_range.is_empty() {
            return;
        }

        if old_range.is_empty() {
            for i in new_range {
                res.push(EditType::Addition(&new[i]));
            }
            return;
        }

        if new_range.is_empty() {
            for i in old_range {
                res.push(EditType::Deletion(&old[i]));
            }
            return;
        }

        let Coordinates {
            old: x_start,
            new: y_start,
        } = Myers::middle_snake(old, old_range.clone(), new, new_range.clone(), frontiers);

        // divide and conquer along the middle snake
        let (old_first_half, old_second_half) = split_range(&old_range, x_start);
        let (new_first_half, new_second_half) = split_range(&new_range, y_start);

        Myers::diff_impl(res, old, old_first_half, new, new_first_half, frontiers);
        Myers::diff_impl(res, old, old_second_half, new, new_second_half, frontiers);
    }
/// A helper implementation function that handles the recursive end of finding a diff using
/// Myers' algorithm.
A helper implementation function that handles the recursive end of finding a diff using
Myers' algorithm.
A helper implementation function that handles the recursive end of finding a diff using Myers ' algorithm .
fn diff_impl<'elem, T: Eq + Debug + 'elem>(
        res: &mut Vec<EditType<&'elem T>>,
        old: &'elem [T],
        mut old_range: Range<usize>,
        new: &'elem [T],
        mut new_range: Range<usize>,
        frontiers: &mut MyersFrontiers,
    ) {
        // Initial optimizations: we can skip the common prefix + suffix
        let common_pref_len = common_prefix_len(old, old_range.clone(), new, new_range.clone());
        old_range.start += common_pref_len;
        new_range.start += common_pref_len;
        let common_suf_len = common_suffix_len(old, old_range.clone(), new, new_range.clone());
        // Need to make sure our begin/end ranges don't overlap
        old_range.end = old_range.start.max(old_range.end - common_suf_len);
        new_range.end = new_range.start.max(new_range.end - common_suf_len);
        // We know if either or both of the inputs are empty, we don't have to bother finding the
        // middle snake
        if old_range.is_empty() && new_range.is_empty() {
            return;
        }
        if old_range.is_empty() {
            for i in new_range {
                res.push(EditType::Addition(&new[i]));
            }
            return;
        }
        if new_range.is_empty() {
            for i in old_range {
                res.push(EditType::Deletion(&old[i]));
            }
            return;
        }
        let Coordinates {
            old: x_start,
            new: y_start,
        } = Myers::middle_snake(old, old_range.clone(), new, new_range.clone(), frontiers);
        // divide and conquer along the middle snake
        let (old_first_half, old_second_half) = split_range(&old_range, x_start);
        let (new_first_half, new_second_half) = split_range(&new_range, y_start);
        Myers::diff_impl(res, old, old_first_half, new, new_first_half, frontiers);
        Myers::diff_impl(res, old, old_second_half, new, new_second_half, frontiers);
    }
fn diff_impl < ' elem , T : Eq + Debug + ' elem > ( res : & mut Vec < EditType < & ' elem T > > , old : & ' elem [ T ] , mut old_range : Range < usize > , new : & ' elem [ T ] , mut new_range : Range < usize > , frontiers : & mut MyersFrontiers , ) { // Initial optimizations: we can skip the common prefix + suffix let common_pref_len = common_prefix_len ( old , old_range . clone ( ) , new , new_range . clone ( ) ) ; old_range . start += common_pref_len ; new_range . start += common_pref_len ; let common_suf_len = common_suffix_len ( old , old_range . clone ( ) , new , new_range . clone ( ) ) ; // Need to make sure our begin/end ranges don't overlap old_range . end = old_range . start . max ( old_range . end - common_suf_len ) ; new_range . end = new_range . start . max ( new_range . end - common_suf_len ) ; // We know if either or both of the inputs are empty, we don't have to bother finding the // middle snake if old_range . is_empty ( ) && new_range . is_empty ( ) { return ; } if old_range . is_empty ( ) { for i in new_range { res . push ( EditType :: Addition ( & new [ i ] ) ) ; } return ; } if new_range . is_empty ( ) { for i in old_range { res . push ( EditType :: Deletion ( & old [ i ] ) ) ; } return ; } let Coordinates { old : x_start , new : y_start , } = Myers :: middle_snake ( old , old_range . clone ( ) , new , new_range . clone ( ) , frontiers ) ; // divide and conquer along the middle snake let ( old_first_half , old_second_half ) = split_range ( & old_range , x_start ) ; let ( new_first_half , new_second_half ) = split_range ( & new_range , y_start ) ; Myers :: diff_impl ( res , old , old_first_half , new , new_first_half , frontiers ) ; Myers :: diff_impl ( res , old , old_second_half , new , new_second_half , frontiers ) ; }
A helper implementation function that handles the recursive end of finding a diff using
Myers' algorithm.
A helper implementation function that handles the recursive end of finding a diff using Myers ' algorithm .
res
&mut Vec<EditType<&'elem T>>
old
&'elem [T]
old_range
Range<usize>
new
&'elem [T]
new_range
Range<usize>
frontiers
&mut MyersFrontiers
res
&mut Vec<EditType<&'elem T>>
old
&'elem [T]
old_range
Range<usize>
new
&'elem [T]
new_range
Range<usize>
frontiers
&mut MyersFrontiers