dir-diff
dir-diff copied to clipboard
Expose a diffing iterator
Some example use cases
- Report more detailed information than
is_different- first diff
- all diffs
- all regular and diffs
- Custom content comparisons
- line-ending agnostic
- Using the
differencecrate
You can look at the implementation of is_different to see how simple it is. I have a test branch of cobalt that replaces the custom directory diffing with this, augmented to use difference:
fn assert_dirs_eq(expected: &Path, actual: &Path) {
for entry in dir_diff::DirDiff::new(expected, actual) {
let entry = entry
.unwrap()
.assert_exists()
.and_then(dir_diff::DiffEntry::assert_file_type)
.and_then(assert_content);
if let Err(error) = entry {
panic!("{}", error);
}
}
}
Controversial API choices
- Prefixing the test functions with
assertdespite them erroring rather thanpanicing. I wasn't sure of a better name
Potential areas for the API to expand
- Make it even easier to get the first or all differences
- Make it easier to have a nice panic
Potential areas for chrome improvement
AssertionError'sDisplay- Have a
fancyfeature that usesdifference- Limit on file size?
- Assume anything convertable to
String/ UTF-8 is text? - Use a extension crate to detect text?
- Use a content sniffer to detect text?
@steveklabnik This is a big change. Is it something you're wanting to look at before I submit?