Unified · Split
| @@ -71,7 +71,7 @@ pub trait ConsumeBinaryHunkDelegate { · 70 unmodified lines | ||
| 71 | 71 | fn consume_binary_hunk(&mut self, header: HunkHeader, header_str: &str, hunk: &[u8]) -> std::io::Result<()>; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | −/// A utility trait for use in [`UnifiedDiff`]. | |
| 74 | +/// A utility trait for use in [`crate::blob::UnifiedDiff`]. | |
| 75 | 75 | pub trait ConsumeHunk { |
| 76 | 76 | /// The item this instance produces after consuming all hunks. |
| 77 | 77 | type Out; |
| @@ -80,7 +80,7 @@ pub trait ConsumeHunk { · 2 unmodified lines | ||
| 80 | 80 | /// and the original token bytes (`&[u8]`) for that line without the unified diff prefix character. |
| 81 | 81 | /// The `header` specifies hunk offsets, which positions the `lines` in the old and new file respectively. |
| 82 | 82 | /// |
| 83 | − /// Note that [`UnifiedDiff`] will wrap its output in an [`std::io::Result`]. | |
| 83 | + /// Note that [`crate::blob::UnifiedDiff`] will wrap its output in an [`std::io::Result`]. | |
| 84 | 84 | /// After this method returned its first error, it will not be called anymore. |
| 85 | 85 | fn consume_hunk(&mut self, header: HunkHeader, lines: &[(DiffLineKind, &[u8])]) -> std::io::Result<()>; |
| 86 | 86 | |
| @@ -182,10 +182,10 @@ mod heuristics { · 181 unmodified lines | ||
| 182 | 182 | |
| 183 | 183 | insta::assert_snapshot!(util::unidiff(&diff, &input), @r#" |
| 184 | 184 | @@ -2,1 +2,1 @@ |
| 185 | − - let x = 1; | |
| 186 | − + let x = 2; | |
| 185 | + - let x = 1; | |
| 186 | + + let x = 2; | |
| 187 | 187 | @@ -4,0 +4,1 @@ |
| 188 | − + println!("done"); | |
| 188 | + + println!("done"); | |
| 189 | 189 | "#); |
| 190 | 190 | Ok(()) |
| 191 | 191 | } |
| @@ -212,10 +212,10 @@ mod heuristics { · 20 unmodified lines | ||
| 212 | 212 | |
| 213 | 213 | insta::assert_snapshot!(util::unidiff(&diff, &input), @r#" |
| 214 | 214 | @@ -2,1 +2,1 @@ |
| 215 | − - let x = 1; | |
| 216 | − + let x = 2; | |
| 215 | + - let x = 1; | |
| 216 | + + let x = 2; | |
| 217 | 217 | @@ -4,0 +4,1 @@ |
| 218 | − + println!("done"); | |
| 218 | + + println!("done"); | |
| 219 | 219 | "#); |
| 220 | 220 | Ok(()) |
| 221 | 221 | } |
| @@ -243,7 +243,7 @@ mod heuristics { · 21 unmodified lines | ||
| 243 | 243 | |
| 244 | 244 | insta::assert_snapshot!(util::unidiff(&diff, &input), @r#" |
| 245 | 245 | @@ -4,0 +4,1 @@ |
| 246 | − + println!("world"); | |
| 246 | + + println!("world"); | |
| 247 | 247 | "#); |
| 248 | 248 | |
| 249 | 249 | Ok(()) |
| @@ -311,12 +311,12 @@ mod heuristics { · 61 unmodified lines | ||
| 311 | 311 | let input = blob::InternedInput::new(before, after); |
| 312 | 312 | let diff = diff_with_slider_heuristics(blob::Algorithm::Histogram, &input); |
| 313 | 313 | |
| 314 | − insta::assert_snapshot!(util::unidiff(&diff, &input), @r" | |
| 314 | + insta::assert_snapshot!(util::unidiff(&diff, &input), @" | |
| 315 | 315 | @@ -3,0 +3,1 @@ |
| 316 | − + y: i32, | |
| 316 | + + y: i32, | |
| 317 | 317 | @@ -7,1 +8,1 @@ |
| 318 | − - Foo { x: 0 } | |
| 319 | − + Foo { x: 0, y: 0 } | |
| 318 | + - Foo { x: 0 } | |
| 319 | + + Foo { x: 0, y: 0 } | |
| 320 | 320 | "); |
| 321 | 321 | |
| 322 | 322 | Ok(()) |
| @@ -91,13 +91,13 @@ · 90 unmodified lines | ||
| 91 | 91 | //! [`Diff::hunks`], which returns a list of additions/removals/modifications in the |
| 92 | 92 | //! order that they appear in the input. |
| 93 | 93 | //! |
| 94 | −//! Finally, if the `unified_diff` feature is enabled, a diff can be printed with | |
| 95 | −//! [`Diff::unified_diff`] to print a unified diff/patch as shown by `git diff` or `diff | |
| 96 | −//! -u`. Note that while the unified diff has a decent amount of flexibility, it is fairly | |
| 94 | +//! Finally, when built with the `unified_diff` feature, this crate also provides a | |
| 95 | +//! built-in unified diff/patch formatter similar to `git diff` or `diff -u`. | |
| 96 | +//! Note that while the formatter has a decent amount of flexibility, it is fairly | |
| 97 | 97 | //! simplistic and not every formatting may be possible. It's meant to cover common |
| 98 | 98 | //! situations but not cover every advanced use case. Instead, if you need more advanced |
| 99 | 99 | //! printing, build your own printer on top of the [`Diff::hunks`] iterator; for that, you can |
| 100 | −//! take inspiration from the built-in printer. | |
| 100 | +//! take inspiration from the built-in printer implementation. | |
| 101 | 101 | //! |
| 102 | 102 | //! ``` |
| 103 | 103 | //! # use gix_imara_diff::{InternedInput, Diff, Algorithm, BasicLineDiffPrinter, UnifiedDiffConfig}; |