macro_rules! open_string_union {
($(#[$meta:meta])* $name:ident { $($(#[$cmeta:meta])* $cname:ident => $val:literal),* $(,)? }) => {
$(#[$meta])*
#[derive(Debug, Clone, PartialEq, Eq, Hash, ::serde::Serialize, ::serde::Deserialize)]
#[serde(transparent)]
pub struct $name(pub String);
impl $name {
$( $(#[$cmeta])* pub const $cname: &'static str = $val; )*
pub fn as_str(&self) -> &str {
&self.0
}
}
impl From<String> for $name {
fn from(s: String) -> Self {
Self(s)
}
}
impl From<&str> for $name {
fn from(s: &str) -> Self {
Self(s.to_string())
}
}
impl ::std::fmt::Display for $name {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str(&self.0)
}
}
};
}
pub(crate) use open_string_union;