facet-diff
facet-diff
Structural diffing for Facet types with human-readable output.
Overview
facet-diff computes differences between two values using reflection.
It works on any type that implements Facet, without requiring manual
diff implementations or PartialEq.
use ;
let old = MyStruct ;
let new = MyStruct ;
let diff = old.diff;
println!;
// Shows: count: 1 → 2
Features
- Reflection-based: Works on any
Facettype automatically - Human-readable output: Multiple output formats (colored, plain, compact)
- Sequence diffing: Uses Myers' algorithm for optimal sequence alignment
- Float tolerance: Configure epsilon for floating-point comparisons
Usage
Basic Diffing
use FacetDiff;
let diff = old_value.diff;
if diff.is_equal else
Formatted Output
use ;
// Full colored diff
let output = format_diff;
// Compact single-line format
let compact = format_diff_compact;
With Options
use ;
use Peek;
let options = new
.with_float_tolerance;
let diff = diff_new_peek_with_options;
Architecture
facet-diff uses facet-reflect to traverse values structurally:
- Peek - facet's reflection API provides access to fields and values
- Myers' algorithm - Optimal diff for sequences (lists, arrays)
- Recursive comparison - Fields compared by structure, not equality
- Layout rendering - facet-diff-core handles output formatting
Related Crates
- facet-diff-core: Core diff types and rendering
- facet-reflect: Reflection API for traversing Facet values
- facet-pretty: Pretty-printing for Facet values
Sponsors
Thanks to all individual sponsors:
...along with corporate sponsors:
...without whom this work could not exist.
Special thanks
The facet logo was drawn by Misiasart.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.