iter-diff

Crates.ioiter-diff
lib.rsiter-diff
version0.1.1
sourcesrc
created_at2022-02-25 22:37:53.947123
updated_at2022-02-25 22:46:29.916087
descriptionDifferences between iterators
homepagehttps://github.com/ureeves/iter-diff
repositoryhttps://github.com/ureeves/iter-diff
max_upload_size
id539688
size21,373
Eduardo Leegwater Simões (ureeves)

documentation

README

iter-diff

Differences between iterators

CI codecov docs.rs


The IterDiff trait can be used to iterate through the differences between two iterators. The differences between each element are enumerated by Diff. The variants of the enum express the changes one would need to make to the left-hand iterator in order to attain the right-hand iterator.

use iter_diff::prelude::*;

let a = [0, 1, 2, 3];
let b = [0, 2, 2];

let diffs: Vec<_> = a.iter_diff(b).collect();
assert_eq!(diffs.len(), 4);

assert_eq!(diffs[0], Diff::Keep);
assert_eq!(diffs[1], Diff::Change(2));
assert_eq!(diffs[2], Diff::Keep);
assert_eq!(diffs[3], Diff::Remove);
Commit count: 5

cargo fmt