diff --git a/src/macros.rs b/src/macros.rs index 92955e9..5af70aa 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -39,6 +39,12 @@ macro_rules! kind { $y, } + impl std::fmt::Display for $x { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, stringify!($y)) + } + } + impl Default for $x { fn default() -> Self { $x::$y @@ -67,3 +73,13 @@ macro_rules! uri { $x.parse::()? }}; } + +#[cfg(test)] +mod tests { + #[test] + fn to_string_works() { + kind!(MyType, My); + + assert_eq!(MyType::My.to_string(), "My") + } +}