Macro function_set

Source
macro_rules! function_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::Function that matches one of the variant names in the enum.

ยงExample

use css_parse::*;
use bumpalo::Bump;
function_set!(
  /// Some docs on this type...
  pub enum Functions {
    Foo: "foo",
    Bar: "bar",
    Baz: "baz"
  }
);

// Matches are case insensitive
assert_parse!(Functions, "FoO(");

// The result will be one of the variants in the enum, matching the keyword.
assert_parse!(Functions, "baR(");

// Words that do not match will fail to parse.
assert_parse_error!(Functions, "bing(");

assert_parse_error!(Functions, "oof(");