From 2d41780bb491c594f1193128f60ca8fabf47ec20 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 19 Apr 2025 14:02:34 -0700 Subject: [PATCH] vtparse: improve CsiParam Debug impl show the byte as a char --- vtparse/src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vtparse/src/lib.rs b/vtparse/src/lib.rs index 8f4483b91..5a1115f49 100644 --- a/vtparse/src/lib.rs +++ b/vtparse/src/lib.rs @@ -397,12 +397,21 @@ pub struct VTParser { /// and I are intermediate bytes in the range 0x20-0x2F /// and F is the final byte in the range 0x40-0x7E /// -#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] pub enum CsiParam { Integer(i64), P(u8), } +impl core::fmt::Debug for CsiParam { + fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { + match self { + Self::Integer(i) => write!(fmt, "Integer({i})"), + Self::P(n) => write!(fmt, "P({})", char::from(*n)), + } + } +} + impl Default for CsiParam { fn default() -> Self { Self::Integer(0) -- 2.51.2