enum Foo {
BAR
}
impl fmt::Display for Foo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}
Usage :
println!("{}", Foo::BAR.to_string())
Cheatsheet collection for go, rust, python, shell and javascript.
enum Foo {
BAR
}
impl fmt::Display for Foo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}
Usage :
println!("{}", Foo::BAR.to_string())