fudiff 0.2.0

Fuzzy Unified Diff
Documentation
  • Coverage
  • 72.22%
    13 out of 18 items documented0 out of 8 items with examples
  • Size
  • Source code size: 47.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.87 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • cortesi/fudiff
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • cortesi

Crates.io Docs License

FuDiff

A Rust library implementing a robust fuzzy unified diff format designed for AI-driven patching tools.

Features

  • Context-based patching without relying on line numbers
  • Fuzzy matching for reliable patch application
  • Clean, minimalist diff format optimized for AI interactions
  • Reversible patches - can apply and revert changes
  • Extensive tests
  • Optional serde support for serialization/deserialization (enable with serde feature)

Usage

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();

Diff Format

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 (@@ @@).

License

MIT