From 7de5893b839f23f64f5a62f6322558e485fd4f9b Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 13 Jan 2023 12:54:28 +0100 Subject: [PATCH] common: Use quoted string as Debug representation of event types --- crates/ruma-macros/src/events/event_type.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/ruma-macros/src/events/event_type.rs b/crates/ruma-macros/src/events/event_type.rs index 40501842..9ce4b635 100644 --- a/crates/ruma-macros/src/events/event_type.rs +++ b/crates/ruma-macros/src/events/event_type.rs @@ -194,7 +194,7 @@ fn generate_enum( /// This type can hold an arbitrary string. To build events with a custom type, convert it /// from a string with `::from() / .into()`. To check for events that are not available as a /// documented variant here, use its string representation, obtained through `.to_string()`. - #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] + #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub enum #ident { #( @@ -222,6 +222,13 @@ fn generate_enum( } } + #[allow(deprecated)] + impl ::std::fmt::Debug for #ident { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::fmt(&self.to_cow_str(), f) + } + } + #[allow(deprecated)] impl ::std::convert::From<&::std::primitive::str> for #ident { fn from(s: &::std::primitive::str) -> Self {