More generic lifetimes for iter_changes and added iter_all_changes

This commit is contained in:
Armin Ronacher 2021-02-04 12:15:20 +01:00
parent b98be24027
commit 12e7d5e4b0
5 changed files with 67 additions and 11 deletions

View file

@ -247,15 +247,16 @@ impl DiffOp {
///
/// `old` and `new` are two indexable objects like the types you pass to
/// the diffing algorithm functions.
pub fn iter_changes<'x, Old, New, T>(
pub fn iter_changes<'x, 'lookup, Old, New, T>(
&self,
old: &'x Old,
new: &'x New,
) -> impl Iterator<Item = Change<'x, T>>
old: &'lookup Old,
new: &'lookup New,
) -> impl Iterator<Item = Change<'x, T>> + 'lookup
where
Old: Index<usize, Output = &'x T> + ?Sized,
New: Index<usize, Output = &'x T> + ?Sized,
T: 'x + ?Sized,
'x: 'lookup,
{
let (tag, old_range, new_range) = self.as_tag_tuple();
let mut old_index = old_range.start;