enum-kinds-macros

Crates.ioenum-kinds-macros
lib.rsenum-kinds-macros
version0.2.1
sourcesrc
created_at2017-05-16 17:38:24.154552
updated_at2018-03-06 10:32:35.73899
descriptionDeprecated in favor of the enum-kinds crate. Generate enums with matching variants but without any of the associated data. enum-kinds-traits crate contains trait definitions used by this crate.
homepagehttps://bitbucket.org/Soft/enum-kinds
repositoryhttps://bitbucket.org/Soft/enum-kinds
max_upload_size
id14843
size9,678
pac (github:rp-rs:pac)

documentation

README

enum-kinds-macros

Build Status Latest Version Rust Documentation

DEPRECATED: This crate along with enum-kinds-traits have been replaced with enum-kinds crate. Users are asked to migrate to the new crate as further development will take place there.

Generate enums with matching variants, but without any of the associated data. enum-kinds-traits crate contains trait definitions used by this crate.

In other words, enum-kinds-macros automatically generates enums that have the same set of variants as the original enum, but with all the embedded data stripped away (that is, all the variants are unit variants). Additionally, enum-kinds-macros implements ToKind trait for the original enum allowing one to get the associated unit variant.

The crates are compatible with stable Rust releases.

Example

#[macro_use]
extern crate enum_kinds_macros;
extern crate enum_kinds_traits;

use enum_kinds_traits::ToKind;

#[derive(EnumKind)]
#[enum_kind_name(SomeEnumKind)]
enum SomeEnum {
    First(String, u32),
    Second(char),
    Third
}

#[test]
fn test_enum_kind() {
    let first = SomeEnum::First("Example".to_owned(), 32);
    assert_eq!(first.kind(), SomeEnumKind::First);
}

The #[derive(EnumKind)] attribute automatically creates another enum named SomeEnumKind that contains matching unit variant for each of the variants in SomeEnum. Additionally, SomeEnum implements ToKind trait that provides the kind method for constructing matching values from SomeEnumKind.

Issues

While the crates are fairly simple, issues are still possible. If you encounter any problems using these crates, please report them at the issue tracker.

License

The crates are available under the terms of MIT license.

Commit count: 0

cargo fmt