common: Use quoted string as Debug representation of event types

This commit is contained in:
Jonas Platte 2023-01-13 12:54:28 +01:00
parent 3a722965f5
commit 7de5893b83
No known key found for this signature in database
GPG Key ID: AAA7A61F696C3E0C

View File

@ -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 {
<str as ::std::fmt::Debug>::fmt(&self.to_cow_str(), f)
}
}
#[allow(deprecated)]
impl ::std::convert::From<&::std::primitive::str> for #ident {
fn from(s: &::std::primitive::str) -> Self {