Expand description
§libxdiff bindings for Rust
This library contains bindings to the libxdiff C library. The
underlying library defines “MMFiles” using chains of non-contiguous buffers
to minimize reallocations when appending and mutating.
This wrapper structures the API by defining all MMFile
s to be compact
(backed by a single buffer). The non-compact form is MMBlocks
.
libxdiff tracks iteration over buffers internally, so some operations that
conceptually are read-only end up requiring &mut
arguments in order to be
safe.
§Example
use core::str::from_utf8;
use libxdiff::MMFile;
let mut f1 = MMFile::from_bytes(b"hello world\n");
let mut f2 = MMFile::from_bytes(b"hello world!\n");
let mut diff_lines = Vec::<String>::new();
f1.diff_raw(&mut f2, |line: &[u8]| {
diff_lines.push(from_utf8(line).unwrap().to_owned());
})
.unwrap();
assert_eq!(
diff_lines,
vec![
"@@ -1,1 +1,1 @@\n",
"-", "hello world\n",
"+", "hello world!\n",
],
);
Structs§
- MMBlocks
- An MMFile that does not have compactness as an invariant
- MMFile
- Type representing an owned, compact file in libxdiff