Attribute Macro utility_types::extract[][src]

#[extract]
Expand description

Constructs an enum by extracting variants in the set from the original enum.

Example

#[extract(Terra, [Mercury, Venus, Earth, Mars], [Debug])]
enum Planet<T> {
    Mercury(T),
    Venus(T),
    Earth(T),
    Mars(T),
    Jupiter(T),
    Saturn(T),
    Uranus(T),
    Neptune(T),
}

The code above will become this:

enum Planet<T> {
    Mercury(T),
    Venus(T),
    Earth(T),
    Mars(T),
    Jupiter(T),
    Saturn(T),
    Uranus(T),
    Neptune(T),
}

#[derive(Debug)]
enum Terra<T> {
    Mercury(T),
    Venus(T),
    Earth(T),
    Mars(T),
}

Notice

Currently, generics are not analyzed. So rustc will complain if the field with generic is not included in the generated enum.