diff --git a/src/diff.rs b/src/diff.rs index 0d3d358b5..ecbd20f92 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,27 @@ where Longer(usize, PutBack), } +impl fmt::Debug for Diff +where + I: Iterator, + J: Iterator, + PutBack: fmt::Debug, + PutBack: 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(), + } + } +} + /// 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`. ///