📚Cheatsheets

Cheatsheet collection for go, rust and javascript.

Convert Enum to String in Rust

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())