Impl display for kinds

This commit is contained in:
asonix 2020-07-17 08:14:23 -05:00
parent e9f3878bd2
commit 857d5167df

View file

@ -39,6 +39,12 @@ macro_rules! kind {
$y, $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 { impl Default for $x {
fn default() -> Self { fn default() -> Self {
$x::$y $x::$y
@ -67,3 +73,13 @@ macro_rules! uri {
$x.parse::<Url>()? $x.parse::<Url>()?
}}; }};
} }
#[cfg(test)]
mod tests {
#[test]
fn to_string_works() {
kind!(MyType, My);
assert_eq!(MyType::My.to_string(), "My")
}
}