Skip to main content

Module diff

Module diff 

Source
Expand description

Diffs: an engine, terminal views and the inputs they read.

  • engine: Myers’ O(ND) diff in linear space over any hashable elements (diff_lines, diff_slices), word and character diffs for intra-line emphasis (diff_words, diff_chars), Hunk grouping and TextDiff, whose unified output matches diff -u minus timestamps.
  • DiffView: a renderable diff, unified or side by side, of plain text, ANSI text (DiffView::ansi, which also reports style-only changes) or, with the testing feature, render snapshots.
  • SourceDiff: a syntax-highlighted source diff with optional line links.
  • git: a git diff parser and PatchView, a review-style renderer with a file tree, annotations and links.
  • test_report (feature test-report): JUnit XML and libtest JSON test results and the TestReport renderable.
  • assert_rich_eq! and friends (feature testing): assertions that panic with a rendered diff.

With colour off every change stays visible: -, + and ~ (style only) markers lead each changed line.

Re-exports§

pub use engine::diff_chars;
pub use engine::diff_lines;
pub use engine::diff_slices;
pub use engine::diff_words;
pub use engine::group_hunks;
pub use engine::hunk_header;
pub use engine::tokenize;
pub use engine::Hunk;
pub use engine::Op;
pub use engine::TextDiff;

Modules§

assert
Assertions that fail with a rendered diff: assert_rich_eq!, assert_rich_json_eq!, assert_render_eq! and assert_snapshot_eq!.
engine
The diff engine: Myers’ O(ND) algorithm in linear space, hunk grouping, token-level diffs for intra-line emphasis and the diff -u text format.
git
git diff output: a parser and a review-style renderer.
test_report
Test results: a format-neutral model, JUnit XML and libtest JSON adapters, a renderable TestReport and JUnit export.
transform
Transforms over a parsed git Patch, for a Pipeline.

Structs§

DiffView
A line diff as a renderable: unified (default) or side by side, with line numbers, hunk headers and word-level emphasis on changed lines.
SourceDiff
A syntax-highlighted diff of two versions of a source file.

Enums§

Layout
How a diff is laid out.
Side
Which side of a diff.

Constants§

STYLES
The default styles for diff and test-report keys. extended_theme includes them; renderers fall back to them when a theme lacks a key.