enum_to_str_derive 0.3.0

provide a simple way to convert enum to static str ref
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use proc_macro_helper::prelude::*;
use syn;

pub fn lit_str_value(source: &syn::Lit) -> Option<String> {
    match source {
        syn::Lit::Str(value) => Some(value.value()),
        _ => None,
    }
}

pub fn target_attributes(source: &Variant) -> impl Iterator<Item = Attribute> + '_ {
    source
        .attributes
        .iter()
        .filter(|x| x.name == "ETS")
        .flat_map(|x| x.sub_nodes.clone())
}