Use write! instead of Display::fmt

Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com>
This commit is contained in:
andrews05 2025-01-30 08:01:54 +13:00 committed by Andrew
parent 00bff4d06d
commit 283de86708
2 changed files with 7 additions and 9 deletions

View file

@ -32,13 +32,11 @@ impl Display for ColorType {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Grayscale { .. } => Display::fmt("Grayscale", f),
Self::RGB { .. } => Display::fmt("RGB", f),
Self::Indexed { palette } => {
Display::fmt(&format!("Indexed ({} colors)", palette.len()), f)
}
Self::GrayscaleAlpha => Display::fmt("Grayscale + Alpha", f),
Self::RGBA => Display::fmt("RGB + Alpha", f),
Self::Grayscale { .. } => write!(f, "Grayscale"),
Self::RGB { .. } => write!(f, "RGB"),
Self::Indexed { palette } => write!(f, "Indexed ({} colors)", palette.len()),
Self::GrayscaleAlpha => write!(f, "Grayscale + Alpha"),
Self::RGBA => write!(f, "RGB + Alpha"),
}
}
}

View file

@ -49,9 +49,9 @@ impl Display for Deflaters {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Libdeflater { compression } => Display::fmt(&format!("zc = {}", compression), f),
Self::Libdeflater { compression } => write!(f, "zc = {compression}"),
#[cfg(feature = "zopfli")]
Self::Zopfli { iterations } => Display::fmt(&format!("zopfli, zi = {}", iterations), f),
Self::Zopfli { iterations } => write!(f, "zopfli, zi = {iterations}"),
}
}
}