[−][src]Function visit_diff::all_different
pub fn all_different<T: ?Sized>(a: &T, b: &T) -> bool where
T: Diff,
Checks if there is something different about every top-level part of a
and b
. For example, if every field of two structs has some difference.
The individual parts are compared using any_difference
.
This is used to adjust the granularity of diff reporting by debug_diff
:
it will show compound types (like structs) as different at the top level if
they are all_different
, or diff individual fields if not.
use visit_diff::{Diff, all_different}; #[derive(Diff, Debug)] struct ExampleStruct { name: &'static str, age: usize, } let left = ExampleStruct { name: "Bob", age: 4 }; let right = ExampleStruct { name: "Rototron 3k", age: 4 }; assert_eq!( all_different(&left, &right), false, "Bob and Rototron have few things in common, but they're the same age.", ); let right = ExampleStruct { age: 5, ..right}; // if we change the age... assert_eq!(all_different(&left, &right), true);