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!andassert_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§
- Diff
Format - Configuration for diff formatting.
- Diff
Options - Configuration options for diff computation
- Diff
Report - A reusable diff plus its original inputs, allowing rendering in different output styles.
- Diff
Symbols - Symbols for diff rendering.
- Diff
Theme - Color theme for diff rendering.
- Interspersed
- An interspersed sequence of A and B values. Pattern: [A?, (B, A)*, B?]
- Leaf
Change - A single leaf-level change in a diff, with path information.
- Path
- A path from root to a node.
- Replace
Group - A group of values being replaced (removals paired with additions).
- Same
Options - Options for customizing structural comparison behavior.
- Updates
- Sequence updates: update groups interspersed with unchanged items.
- Updates
Group - A group of updates containing replace groups interspersed with nested diffs.
Enums§
- Change
Kind - The kind of change for a diff element.
- Diff
- The difference between two values.
- Leaf
Change Kind - The kind of leaf change.
- Path
Segment - A path segment describing how to reach a child.
- Same
Report - 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§
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
Peekvalues (backward compatibility wrapper) - diff_
new_ peek_ with_ options - Computes the difference between two
Peekvalues 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.