( ... )`.
Please checkout the `examples` directory of the [source repo](https://github.com/AnubhabB/diff-match-patch-rs/tree/main/examples) for a few common use-cases.
The `Effitient` and `Compat` modes are mutually exclusive and will not generate correct output if used interchangibly at source and destination
## Benchmarks
Benchmarks are maintained [diff-match-patch-bench repository](https://github.com/AnubhabB/diff-match-patch-rs-bench)
| Lang. | Library | Diff Avg. | Patch Avg. | Bencher | Mode | Correct |
|:-------:|:----------------------------------------------------------------------------------------:|:---------:|:----------:|:----------:|:-----------:|:-------:|
| `rust` | [diff_match_patch v0.1.1](https://crates.io/crates/diff_match_patch)[^2] | 68.108 ms | 10.596 ms | Criterion | - | โ
|
| `rust` | [dmp v0.2.0](https://crates.io/crates/dmp) | 69.019 ms | 14.654 ms | Criterion | - | โ
|
| `rust` | [diff-match-patch-rs](https://github.com/AnubhabB/diff-match-patch-rs.git)our | 64.66 ms | 631.13 ยตs | Criterion | `Efficient` | โ
|
| `rust` | [diff-match-patch-rs](https://github.com/AnubhabB/diff-match-patch-rs.git)our | 64.68 ms | 1.1703 ms | Criterion | `Compat` | โ
|
| `go` | [go-diff](https://github.com/sergi/go-diff) | 50.31 ms | 135.2 ms | go test | - | โ
|
| `node` | [diff-match-patch](https://www.npmjs.com/package/diff-match-patch)[^1] | 246.90 ms | 1.07 ms | tinybench | - | โ |
| `python`| [diff-match-patch](https://pypi.org/project/diff-match-patch/) | 1.01 s | 0.25 ms | timeit | - | โ
|
[^1]: [diff-match-patch](https://www.npmjs.com/package/diff-match-patch) generated `patch text` and `delta` breaks on `unicode surrogates`.
[^2]: Adds an extra clone to the iterator because the `patch_apply` method takes mutable refc. to `diffs`.
## Gotchas
**Diff incompatibility with `JavaScript` libs**:
There are 2 kinds of implementations - one which use a `postprocessing` function for merging `unicode surrogates` which break compatibility with every other popular `diff-match-patch` implementations and the other kind (packages based on the original implementation) break while `urlEncode()` of unicode surrogates.
As of now, this crate brakes compatibility while working with `JS` generated diffs with the surrogate patch.
If you are interfacing with `JavaScript` in browser, using this crate through `wasm` would be ideal.
## Related projects
Diff Match Patch was originally built in 2006 to power Google Docs.
- [Diff Match Patch](https://github.com/google/diff-match-patch) (and it's [fork](https://github.com/dmsnell/diff-match-patch))
- **Rust**: [Distil.io diff_match_patch](https://crates.io/crates/diff_match_patch)
- **Rust**: [dmp](https://crates.io/crates/dmp)
- **Rust**: [Dissimilar](https://crates.io/crates/dissimilar) by the awesome [David Tolnay](https://github.com/dtolnay)
- **Rust**: [diff_match_patch](https://crates.io/crates/diff_match_patch)