Repository: rust-itertools/itertools (language: rust)

Issue:
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:
```rust
// 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);
```


Discussion / hints:
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.

Fix patch:
diff --git a/src/diff.rs b/src/diff.rs
index 0d3d358b5..acef16ecc 100644
--- a/src/diff.rs
+++ b/src/diff.rs
@@ -5,6 +5,8 @@
 //! describes the difference between two non-`Clone` iterators `I` and `J` after breaking ASAP from
 //! a lock-step comparison.
 
+use std::fmt;
+
 use crate::free::put_back;
 use crate::structs::PutBack;
 
@@ -26,6 +28,43 @@ where
     Longer(usize, PutBack<J>),
 }
 
+impl<I, J> fmt::Debug for Diff<I, J>
+where
+    I: Iterator,
+    J: Iterator,
+    PutBack<I>: fmt::Debug,
+    PutBack<J>: fmt::Debug,
+{
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        match self {
+            Self::FirstMismatch(idx, i, j) => f
+                .debug_tuple("FirstMismatch")
+                .field(idx)
+                .field(i)
+                .field(j)
+                .finish(),
+            Self::Shorter(idx, i) => f.debug_tuple("Shorter").field(idx).field(i).finish(),
+            Self::Longer(idx, j) => f.debug_tuple("Longer").field(idx).field(j).finish(),
+        }
+    }
+}
+
+impl<I, J> Clone for Diff<I, J>
+where
+    I: Iterator,
+    J: Iterator,
+    PutBack<I>: Clone,
+    PutBack<J>: Clone,
+{
+    fn clone(&self) -> Self {
+        match self {
+            Self::FirstMismatch(idx, i, j) => Self::FirstMismatch(*idx, i.clone(), j.clone()),
+            Self::Shorter(idx, i) => Self::Shorter(*idx, i.clone()),
+            Self::Longer(idx, j) => Self::Longer(*idx, j.clone()),
+        }
+    }
+}
+
 /// Compares every element yielded by both `i` and `j` with the given function in lock-step and
 /// returns a [`Diff`] which describes how `j` differs from `i`.
 ///


Test patch: