itertools
itertools copied to clipboard
impl debug trait for diff enum
I added a fairly simple yet informative fmt::Debug implementation to the Diff enum. The reasoning behind this is to simplify tests where you just want to say:
// Diff some expected iter with the actual outputted one
let diff = itertools::diff_with(ex, out, |a, b| a == b);
// Now, all you care about is that there is no difference
// If there is, the index of the diff will be logged by assert_eq!
// since diff now impls fmt::Debug
assert_eq!(None, diff);
I just realized my sample scenario won't work even with the fmt::Debug impl since assert_eq! requires Eq/PartialEq to be implemented. If this PR is accepted, then I will open another providing a simple implementation of PartialEq.
I'd prefer a #[derive(Debug)] impl—the property that you can generally copy a debug output and paste it into source code is really useful!
If this PR is accepted, then I will open another providing a simple implementation of PartialEq.
Iterators usually don't provide a PartialEq implementation, so this wouldn't be very helpful.