Skip to main content

Crate rediff

Crate rediff 

Source
Expand description

Diff and compare Facet values with detailed structural difference reporting.

This crate provides:

  • Structural diffing of Facet types without requiring PartialEq
  • Pretty assertions via assert_same! and assert_sameish! macros
  • Multi-format rendering (Rust, JSON, XML styles)
  • ANSI colored terminal output

§Quick Start

use facet::Facet;
use rediff::assert_same;

#[derive(Facet)]
struct Point { x: i32, y: i32 }

let a = Point { x: 10, y: 20 };
let b = Point { x: 10, y: 20 };
assert_same!(a, b);

§Diffing Values

use facet::Facet;
use rediff::{FacetDiff, format_diff_default};

#[derive(Facet)]
struct Config {
    host: String,
    port: u16,
}

let old = Config { host: "localhost".into(), port: 8080 };
let new = Config { host: "localhost".into(), port: 9000 };

let diff = old.diff(&new);
println!("{}", format_diff_default(&diff));

Re-exports§

pub use layout::AnsiBackend;
pub use layout::BuildOptions;
pub use layout::ColorBackend;
pub use layout::DiffFlavor;
pub use layout::JsonFlavor;
pub use layout::PlainBackend;
pub use layout::RenderOptions;
pub use layout::RustFlavor;
pub use layout::XmlFlavor;
pub use layout::build_layout;
pub use layout::render_to_string;

Modules§

layout
Layout types and algorithms for diff rendering.

Macros§

assert_same
Asserts that two values are structurally the same.
assert_same_with
Asserts that two values are structurally the same with custom options.
assert_sameish
Asserts that two values of potentially different types are structurally the same.
assert_sameish_with
Asserts that two values of different types are structurally the same with custom options.
debug
Emit a debug-level log message (no-op version).
debug_assert_same
Asserts that two values are structurally the same (debug builds only).
debug_assert_same_with
Asserts that two values are structurally the same with custom options (debug builds only).
debug_assert_sameish
Asserts that two values of different types are structurally the same (debug builds only).
debug_assert_sameish_with
Asserts that two values of different types are structurally the same with options (debug builds only).
trace
Emit a trace-level log message (no-op version).
trace_verbose
Emit an extremely verbose trace-level log message (no-op version).

Structs§

DiffFormat
Configuration for diff formatting.
DiffOptions
Configuration options for diff computation
DiffReport
A reusable diff plus its original inputs, allowing rendering in different output styles.
DiffSymbols
Symbols for diff rendering.
DiffTheme
Color theme for diff rendering.
Interspersed
An interspersed sequence of A and B values. Pattern: [A?, (B, A)*, B?]
LeafChange
A single leaf-level change in a diff, with path information.
Path
A path from root to a node.
ReplaceGroup
A group of values being replaced (removals paired with additions).
SameOptions
Options for customizing structural comparison behavior.
Updates
Sequence updates: update groups interspersed with unchanged items.
UpdatesGroup
A group of updates containing replace groups interspersed with nested diffs.

Enums§

ChangeKind
The kind of change for a diff element.
Diff
The difference between two values.
LeafChangeKind
The kind of leaf change.
PathSegment
A path segment describing how to reach a child.
SameReport
Detailed comparison result that retains the computed diff.
Sameness
Result of checking if two values are structurally the same.
Value
A set of updates, additions, deletions, insertions etc. for a tuple or a struct

Traits§

FacetDiff
Extension trait that provides a diff method for Facet types

Functions§

check_same
Check if two Facet values are structurally the same.
check_same_report
Check if two Facet values are structurally the same, returning a detailed report.
check_same_with
Check if two Facet values are structurally the same, with custom options.
check_same_with_report
Detailed comparison with custom options.
check_sameish
Check if two Facet values of potentially different types are structurally the same.
check_sameish_report
Check if two Facet values of different types are structurally the same, returning a detailed report.
check_sameish_with
Check if two Facet values of different types are structurally the same, with custom options.
check_sameish_with_report
Detailed cross-type comparison with custom options.
collect_leaf_changes
Collect all leaf-level changes with their paths.
diff_new_peek
Computes the difference between two Peek values (backward compatibility wrapper)
diff_new_peek_with_options
Computes the difference between two Peek values with options
format_diff
Format the diff with the given configuration.
format_diff_compact
Format the diff in compact mode (path-based, no tree structure).
format_diff_compact_plain
Format the diff in compact mode without colors.
format_diff_default
Format the diff with default configuration.