#枚举 #静态 #

无std enum_properties

用于在枚举变体上声明静态属性的宏

4个版本 (2个重大更新)

0.3.0 2021年5月19日
0.2.1 2020年3月31日
0.2.0 2020年3月31日
0.1.0 2020年3月6日

Rust模式 中排名第2043

Download history • Rust 包仓库 20/week @ 2024-03-11 • Rust 包仓库 9/week @ 2024-03-18 • Rust 包仓库 5/week @ 2024-03-25 • Rust 包仓库 34/week @ 2024-04-01 • Rust 包仓库 59/week @ 2024-04-08 • Rust 包仓库 10/week @ 2024-04-15 • Rust 包仓库 13/week @ 2024-04-22 • Rust 包仓库 10/week @ 2024-04-29 • Rust 包仓库 14/week @ 2024-05-06 • Rust 包仓库 22/week @ 2024-05-13 • Rust 包仓库 10/week @ 2024-05-20 • Rust 包仓库 10/week @ 2024-05-27 • Rust 包仓库 16/week @ 2024-06-03 • Rust 包仓库 12/week @ 2024-06-10 • Rust 包仓库 13/week @ 2024-06-17 • Rust 包仓库 9/week @ 2024-06-24 • Rust 包仓库

每月下载量51
用于 6 个crate (2个直接使用)

Apache-2.0

10KB
101

enum_properties

Documentation

用于在枚举变体上声明静态属性的宏。有关更多信息,请参阅文档

示例

use enum_properties::enum_properties;

struct SolidProperties {
    verts: i32,
    edges: i32,
    faces: i32,
}

enum_properties! {
    #[derive(Clone, Copy, Debug)]
    enum PlatonicSolid: SolidProperties {
        Tetrahedron {
            verts: 4,
            edges: 6,
            faces: 4,
        },
        Cube {
            verts: 8,
            edges: 12,
            faces: 6,
        },
        Octahedron {
            verts: 6,
            edges: 12,
            faces: 8,
        },
        Dodecahedron {
            verts: 20,
            edges: 30,
            faces: 12,
        },
        Icosahedron {
            verts: 12,
            edges: 30,
            faces: 20,
        },
    }
}

fn main() {
    let cube = PlatonicSolid::Cube;
    assert_eq!(cube.verts - cube.edges + cube.faces, 2);
}

无运行时依赖