From 921bebcba0232cb1100535337a63bc42c280a9aa Mon Sep 17 00:00:00 2001 From: patrickariel <161032380+patrickariel@users.noreply.github.com> Date: Sat, 21 Dec 2024 00:44:58 +0700 Subject: [PATCH] Implement Debug manually for UnderfilledError --- src/errors.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index ad8d3a2..6cffaaa 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -50,7 +50,7 @@ impl fmt::Debug for CapacityError { } /// Error value indicating that capacity is not completely filled -#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Eq, Ord, PartialEq, PartialOrd)] pub struct UnderfilledError(ArrayVec); impl UnderfilledError { @@ -63,11 +63,27 @@ impl UnderfilledError { } } +impl fmt::Debug for UnderfilledError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!( + f, + "UnderfilledError: capacity is not filled: expected {}, got {}", + CAP, + self.0.len() + ) + } +} + #[cfg(feature="std")] -impl Error for UnderfilledError {} +impl Error for UnderfilledError {} -impl fmt::Display for UnderfilledError { +impl fmt::Display for UnderfilledError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "capacity is not filled: expected {}, got {}", CAP, self.0.len()) + write!( + f, + "capacity is not filled: expected {}, got {}", + CAP, + self.0.len() + ) } } \ No newline at end of file