pkenum_macro 0.3.1

Procedural macros for pkenum.
Documentation
use proc_macro_error::{ abort, proc_macro_error };
use proc_macro::TokenStream;
use pkenum_core::pipeline::derive_display_impl;

/// Use this on an enum to implement `std::fmt::Display` on it.
///
/// Generates an `impl` for `fn to_static_str(&self) -> &'static str`
/// Having a function with a similar signature will cause a collision.
///
/// # Example
/// ```
/// # use pkenum_macro::Display;
///
/// #[derive(Display)]
/// enum IpAddrKind {
///     V4,
///     V6,
/// }
/// ```
#[proc_macro_error]
#[proc_macro_derive(Display)]
pub fn derive_display(tokens: TokenStream) -> TokenStream {
    derive_display_impl(tokens.into())
        .unwrap_or_else(|err| abort!(err.tokens, err.error; help = err.help))
        .into()
}