enum_properties

Crates.ioenum_properties
lib.rsenum_properties
version0.3.0
sourcesrc
created_at2020-03-06 16:32:12.649029
updated_at2021-05-19 18:09:04.368867
descriptionA macro for declaring static properties on enum variants
homepage
repositoryhttps://github.com/cofinite/enum_properties
max_upload_size
id216098
size26,427
Tamme Schichler (Tamschi)

documentation

README

enum_properties

Documentation

A macro for declaring static properties on enum variants. See the documentation for more information.

Example

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);
}
Commit count: 26

cargo fmt