Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ureeves/iter-diff
Differences between iterators
https://github.com/ureeves/iter-diff
Last synced: 4 days ago
JSON representation
Differences between iterators
- Host: GitHub
- URL: https://github.com/ureeves/iter-diff
- Owner: ureeves
- License: apache-2.0
- Created: 2022-02-22T00:55:25.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-02-25T23:00:29.000Z (over 2 years ago)
- Last Synced: 2024-10-31T11:48:54.589Z (18 days ago)
- Language: Rust
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# iter-diff
#### Differences between iterators
[![CI][ci-badge]][ci-url]
[![codecov][codecov-badge]][codecov-url]
[![docs.rs][docs-badge]][docs-url][ci-badge]: https://img.shields.io/github/workflow/status/ureeves/iter-diff/CI?logo=github
[ci-url]: https://github.com/ureeves/iter-diff/actions/workflows/main.yml
[codecov-badge]: https://img.shields.io/codecov/c/gh/ureeves/iter-diff?logo=codecov
[codecov-url]: https://codecov.io/gh/ureeves/iter-diff
[docs-badge]: https://img.shields.io/docsrs/iter-diff?color=blue&logo=rust&logoColor=orange
[docs-url]: https://docs.rs/iter-diff---
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.```rust
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);
```