thediff
A small Rust crate for calculating how different two files are, expressed as a percentage.
It is useful for file comparison, integrity checks, similarity analysis, or detecting changes
between binary or text files.
Installation
Add the crate to your Cargo.toml:
[]
= "0.1"
Usage
Compare Two Strings
use thediff_strings;
Compare Two Files
use Path;
use thediff_files;
use Path;
use thediff_files_async;
async
How It Works
The crate compares files utf8 char by char:
- Counts how many chars differ
- Handles files of different sizes
- Extra bytes in the longer file are treated as differences
Examples
| File A | File B | Result |
|---|---|---|
| Identical | Identical | 0% |
| 50% bytes differ | Same length | 50% |
| One file empty | Other non-empty | 100% |