implement custom Debug for MiniCore

When the contents correspond to the default, just output
`MiniCore("<default>")` instead of the whole thing.

Helps reduce the length of the debug output in the common case.
This commit is contained in:
Ada Alakbarova
2026-04-16 10:59:37 +02:00
parent 19a8a2dfa9
commit 8463b33a01
@@ -385,7 +385,7 @@ pub enum Severity {
Allow,
}
#[derive(Debug, Clone, Copy)]
#[derive(Clone, Copy)]
pub struct MiniCore<'a>(&'a str);
impl<'a> MiniCore<'a> {
@@ -400,6 +400,15 @@ pub const fn default() -> Self {
}
}
impl std::fmt::Debug for MiniCore<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("MiniCore")
// don't print the whole contents if they correspond to the default
.field(if self.0 == test_utils::MiniCore::RAW_SOURCE { &"<default>" } else { &self.0 })
.finish()
}
}
impl<'a> Default for MiniCore<'a> {
#[inline]
fn default() -> Self {