Got it. Concrete / simplified… not always easy to choose. I actually have two different uses for this. Here’s one, in a learner project. I’ll shorten, but at least it’s more concrete:
//html.zig
pub const Tags = enum {
article, aside, footer, header, main, nav, section, // semantic
b, big, i, small, strong, em, mark, code, samp, kbd, var_, cite, dfn, abbr, time, ruby, rt, rp, q, blockquote, pre, address, ins, del, // text formatting
div, span, p, h1, h2, h3, h4, h5, h6, hr, br, wbr, // structural and layout
//...
}
pub const Attributes = enum {
accept, accept_charset, accesskey, action, align_, allow, alpha, alt, as,
//...
};
const ValidAttributes = struct {
const accept: []const Tags = &.{ .form, .input };
const accept_charset: []const Tags = &.{ .form };
const accesskey: []const Tags = &.{ .article, .aside, .footer, }; // ... GLOBAL attribute
const action: []const Tags = &.{ .form };
const align_: []const Tags = &.{ .caption, .col, .colgroup, .hr, .iframe, .img, .table, .tbody, .td, .tfoot, .th, .thead, .tr }; // DEPRECATED
//...
};
The map would be used to validate that code which looks to assign an attribute to an element does so according to the rules; if the attribute is not allowed to be assigned to the given element (lookup-table used here), compile error is issued.