From de448a04dc594f0938210abaa12de0e168f5741a Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 15 May 2026 23:03:07 +0800 Subject: Replace derive-macro Display impl with manual formatting --- mingling_core/src/program/error.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'mingling_core') diff --git a/mingling_core/src/program/error.rs b/mingling_core/src/program/error.rs index 5e92a42..a6874cf 100644 --- a/mingling_core/src/program/error.rs +++ b/mingling_core/src/program/error.rs @@ -4,11 +4,22 @@ use thiserror::Error; /// Error type returned when a panic occurs during execution. #[derive(Error)] -#[error("execution panicked: {payload:?}")] pub struct ProgramPanic { pub payload: Box, } +impl fmt::Display for ProgramPanic { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if let Some(s) = self.payload.downcast_ref::<&str>() { + write!(f, "{}", s) + } else if let Some(s) = self.payload.downcast_ref::() { + write!(f, "{}", s) + } else { + write!(f, "") + } + } +} + impl ProgramPanic { pub fn new(payload: Box) -> Self { ProgramPanic { payload } -- cgit