Crate unidiff

source ·
Expand description

Unified diff parsing/metadata extraction library for Rust

Examples

extern crate unidiff;

use unidiff::PatchSet;

fn main() {
    let diff_str = "diff --git a/added_file b/added_file
new file mode 100644
index 0000000..9b710f3
--- /dev/null
+++ b/added_file
@@ -0,0 +1,4 @@
+This was missing!
+Adding it now.
+
+Only for testing purposes.";
    let mut patch = PatchSet::new();
    patch.parse(diff_str).ok().expect("Error parsing diff");
}

Structs

Each of the modified blocks of a file
A diff line
Unfied patchset
Patch updated file, contains a list of Hunks

Enums

Error type

Constants

Diff line is added
Diff line is context
Diff line is empty
Diff line is removed

Type Definitions

unidiff::parse result type