macro_rules! atkeyword_set {
($(#[$meta:meta])* $vis:vis enum $name: ident { $( $variant: ident: $variant_str: tt$(,)?)+ }) => { ... };
($(#[$meta:meta])* $vis:vis struct $name: ident $str: tt) => { ... };
}
Expand description
A macro for defining an enum which captures a token with Kind::AtKeyword that matches one of the variant names in the enum.
ยงExample
use css_parse::*;
use bumpalo::Bump;
atkeyword_set!(
/// Some docs on this type...
pub enum Keywords {
Foo: "foo",
Bar: "bar",
Baz: "baz"
}
);
// Matches are case insensitive
assert_parse!(Keywords, "@FoO");
// The result will be one of the variants in the enum, matching the keyword.
assert_parse!(Keywords, "@baR");
// Words that do not match will fail to parse.
assert_parse_error!(Keywords, "@bing");
assert_parse_error!(Keywords, "@oof");