Closed madsmtm closed 8 months ago
The LCS implementation does not always call finish at the end of its execution. This can cause issues when used with diff hooks like Replace.
finish
Replace
You can use the code below as a regression test.
use similar::algorithms::{lcs, DiffHook}; struct HasRunFinish(bool); impl DiffHook for HasRunFinish { type Error = (); fn finish(&mut self) -> Result<(), Self::Error> { self.0 = true; Ok(()) } } let mut d = HasRunFinish(false); let slice = &[1, 2]; lcs::diff(&mut d, slice, 0..slice.len(), slice, 0..slice.len()).unwrap(); assert!(d.0);
The LCS implementation does not always call
finish
at the end of its execution. This can cause issues when used with diff hooks likeReplace
.You can use the code below as a regression test.