codecraft 0.2.0

A minimalist 3D game engine built on parts of Bevy (ECS, color) with wgpu and winit: OpenPBR materials, clustered lighting, a yakui-drawn UI, audio and gamepad haptics; its binary maps any folder, and the symbols of its Rust files, as a 3D wall of boxes
Documentation
//! The icons compiled into the binary: the drawn subset of the
//! [`path`](super::path) catalogue, since all 1500 SVGs would be six megabytes.

macro_rules! embed {
    ($($path:expr),* $(,)?) => {
        /// Every embedded icon, as (path, svg).
        pub const ALL: &[(&str, &str)] = &[
            $((
                $path,
                include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/", $path)),
            ),)*
        ];

        /// The SVG behind an icon path, if it is one of the ones built in.
        pub fn source(path: &str) -> Option<&'static str> {
            ALL.iter()
                .find(|(known, _)| *known == path)
                .map(|(_, svg)| *svg)
        }
    };
}

embed![
    "icons/crown.svg",         // the king
    "icons/crown-simple.svg",  // the queen
    "icons/castle-turret.svg", // the rook
    "icons/horse.svg",         // the knight
    "icons/church.svg",        // the bishop
    "icons/circle.svg",        // the pawn
    "icons/cube.svg",
    "icons/shapes.svg",
    "icons/lightbulb.svg",
    "icons/sun.svg",
    "icons/lamp.svg",
    "icons/camera.svg",
    "icons/grid-four.svg",
    "icons/list-bullets.svg",
    "icons/sliders.svg",
    "icons/cards-three.svg",
    "icons/clock.svg",
    "icons/play.svg",
    "icons/pencil.svg",
    "icons/plug.svg",
    "icons/gear.svg",
    "icons/info.svg",
    "icons/sign-out.svg",
    "icons/folder.svg",
    // The kinds of file the code map tiles stand for, until a thumbnail comes.
    "icons/file.svg",
    "icons/file-rs.svg",
    "icons/file-code.svg",
    "icons/file-text.svg",
    "icons/file-md.svg",
    "icons/file-image.svg",
    "icons/file-svg.svg",
    "icons/file-audio.svg",
    "icons/file-video.svg",
    "icons/file-zip.svg",
    "icons/file-pdf.svg",
    "icons/text-aa.svg",
    "icons/floppy-disk.svg",
    "icons/export.svg",
    "icons/image.svg",
    "icons/monitor.svg",
    "icons/target.svg",
    "icons/eye.svg",
    "icons/eye-slash.svg",
    "icons/plus.svg",
    "icons/x.svg",
    "icons/caret-up.svg",
    "icons/caret-down.svg",
    "icons/caret-left.svg",
    "icons/caret-right.svg",
    "icons/wrench.svg",
    "ui/pointer-up.svg",
    "ui/pointer-down.svg",
    "ui/pointer-left.svg",
    "ui/pointer-right.svg",
];

#[cfg(test)]
mod tests {
    #[test]
    fn every_embedded_icon_has_a_name() {
        for (path, _) in super::ALL {
            // Ours are named in `icons::ours`, not in Phosphor's catalogue.
            if crate::ui::icons::ours::ALL.contains(path) {
                continue;
            }
            assert!(
                crate::ui::icons::path::ALL
                    .iter()
                    .any(|(_, known)| known == path),
                "{path} is embedded but is not in `path::ALL`",
            );
        }
    }
}