(&'a self, other: &'a Self)
| 7 | type Diff = Vec<string::Edit>; |
| 8 | |
| 9 | fn diff(&'a self, other: &'a Self) -> edit::Edit<Self> { |
| 10 | let s = lcs::lcs( |
| 11 | || self.chars(), |
| 12 | || other.chars(), |
| 13 | self.chars().count(), |
| 14 | other.chars().count(), |
| 15 | ) |
| 16 | .map(Into::into) |
| 17 | .collect::<Vec<_>>(); |
| 18 | |
| 19 | if s.iter().all(string::Edit::is_copy) { |
| 20 | edit::Edit::Copy(self) |
| 21 | } else { |
| 22 | edit::Edit::Change(s) |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | impl<'a> Diffable<'a> for String { |