macro_rules! define_keywords {
    ($vis:vis mod $modname:ident { $($kw:ident)* }) => { ... };
}
Expand description

Declares a module containing custom keywords as defined by custom_keyword!, and a Keywords marker type for CustomIdent implementing KeywordList.

define_keywords!{
    mod kw {
        foo bar quux
    }
}

// Idiom for using `CustomIdent`
type MyIdent = CustomIdent<kw::Keywords>;

// Valid keywords in this language
let id_self: MyIdent = "self".parse()?;
assert_eq!(id_self, "self");

let id_async: MyIdent = "async".parse()?;
assert_eq!(id_async, "async");

let id_baz: MyIdent = "baz".parse()?;
assert_eq!(id_baz, "baz");

let id_multi_part: MyIdent = "multi_part".parse()?;
assert_eq!(id_multi_part, "multi_part");

// Invalid keywords
let invalid: Result<MyIdent> = "quux".parse();
assert!(invalid.is_err());