File: README.md

package info (click to toggle)
rust-patchkit 0.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 1,160 kB
  • sloc: makefile: 4
file content (38 lines) | stat: -rw-r--r-- 846 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Parsing and manipulation of patch files
---------------------------------------

This crate provides support for parsing and editing of unified diff files, as
well as related files (e.g. quilt).

## Features

- **Traditional parsing**: Parse patch files into structured data
- **Lossless parsing** (new): Parse patch files while preserving all formatting and whitespace using the `edit` module

## Example

```rust
use patchkit::edit;

let patch_text = r#"--- a/file.txt
+++ b/file.txt
@@ -1,3 +1,3 @@
 line 1
-line 2
+line 2 modified
 line 3
"#;

let parsed = edit::parse(patch_text);
let patch = parsed.tree();

for patch_file in patch.patch_files() {
    for hunk in patch_file.hunks() {
        for line in hunk.lines() {
            if let Some(text) = line.text() {
                println!("{}", text);
            }
        }
    }
}
```