enum-strings 0.1.0

Derive a const fn per named string on a unit enum, every variant required to supply every string
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use enum_strings::EnumStrings;

#[derive(Clone, Copy, EnumStrings)]
pub enum Route {
    #[strings(path = "/", label = "Home")]
    Home,
    #[strings(label = "Docs", path = "/docs")]
    Docs,
}

const HOME: &str = Route::Home.path();

fn main() {
    assert_eq!(HOME, "/");
    assert_eq!(Route::Docs.path(), "/docs");
    assert_eq!(Route::Docs.label(), "Docs");
}