Impl display for kinds
This commit is contained in:
parent
e9f3878bd2
commit
857d5167df
1 changed files with 16 additions and 0 deletions
|
@ -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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue