Enum Variant Type
Proc macro derive to generate structs from enum variants.
This is a poor-man's implementation of https://github.com/rust-lang/rfcs/pull/2593.
[]
= "0.3.0"
Examples
use EnumVariantType;
// Now you can do the following:
use TryFrom;
let unit: Unit = try_from.unwrap;
let tuple: Tuple = try_from.unwrap;
let named: Struct = try_from
.unwrap;
let enum_unit = from;
let enum_tuple = from;
let enum_struct = from;
// If the enum variant doesn't match the variant type, then the original variant is returned in
// the `Result`'s `Err` variant.
assert_eq!;
use TryFrom;
/// Unit variant.
;
/// Tuple variant.
;
/// Struct variant.
#
#
Additional options specified by an evt
attribute on enum:
#[evt(derive(Clone, Copy))]
: DerivesClone
,Copy
on every variant.#[evt(module = "module1")]
: Generated structs are placed intomod module1 { ... }
.#[evt(implement_marker_traits(MarkerTrait1))]
: Generated structs allimpl MarkerTrait1
.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.