icon_named!() { /* proc-macro */ }Expand description
Generate a custom icon enum and its IconNamed impl by scanning a directory of SVG files.
Accepts an enum name, a path, and optionally a list of additional derive traits.
Each .svg file becomes an enum variant using PascalCase conversion.
The path may be either:
- A literal path (the common case), resolved relative to the calling crate’s
CARGO_MANIFEST_DIR. Use this when the icons live inside your own package. - An env-var reference of the form
"$NAME", whereNAMEnames a build-time environment variable whose value is the absolute path to the icons directory. Use this when the icons live in another crate and the path is plumbed through cargo’slinks/DEP_<X>_<KEY>propagation mechanism. The defaultIconNameenum ingpui-componentuses this pattern to consume icons fromgpui-kit-assetswithout a sibling-crate reference, which would otherwise breakcargo vendorandcargo publish.
§Example
ⓘ
// Literal path (relative to the calling crate's CARGO_MANIFEST_DIR)
icon_named!(IconName, "icons");
// Env-var reference (resolved at macro expansion time)
icon_named!(IconName, "$GPUI_KIT_DEFAULT_ICONS_DIR");
// With custom derives
icon_named!(IconName, "icons", [Debug, Copy, PartialEq, Eq]);