| Crates.io | fudiff |
| lib.rs | fudiff |
| version | 0.2.0 |
| created_at | 2025-02-04 05:31:44.123634+00 |
| updated_at | 2025-02-04 07:19:30.54301+00 |
| description | Fuzzy Unified Diff |
| homepage | |
| repository | https://github.com/cortesi/fudiff |
| max_upload_size | |
| id | 1541579 |
| size | 47,683 |
A Rust library implementing a robust fuzzy unified diff format designed for AI-driven patching tools.
use fudiff::{diff, parse};
// Create a diff between two strings
let diff = diff("old content", "new content");
// Parse an existing diff
let diff = parse("@@ @@\n-old\n+new\n").unwrap();
// Apply a diff
let patched = diff.patch("old content").unwrap();
// Revert a diff
let original = diff.revert("new content").unwrap();
The format uses context lines (prefixed with space), deletions (prefixed with
-), and additions (prefixed with +):
@@ @@
fn compute(x: i32) -> i32 {
- let y = x * 2;
- println!("Value: {}", y);
+ let y = x + 10;
+ println!("Result: {}", y);
+ println!("Input was: {}", x);
y
}
The patch is located by matching the unchanged context lines rather than using
line numbers. Multiple changes are separated by hunk headers (@@ @@).
MIT