//! wrapped_enum! - Wrap multiple types into an Enum
//!
//! This is useful when returning multiple types. Let that be via a try! / return Err(..)
or
//! simply to just work on an enum of known types.
//!
//! Note: All variants must contain exactly one argument - to return
//!
//!
//! #[derive(Debug)]
//! pub enum LocalError { AliceDidIt, BobDidIt }
//!
//! wrapped_enum!{
//! #[derive(Debug)]
//! /// Document your enums!
//! pub enum {
//! /// Variants too
//! Io(io::Error),
//! /// How to deal with things that return Option when you need some verbosity for Err.
//! ThisModulesName(LocalError),
//! }
//! }
//!
macrorules! wrappedenum { ($(#[$attr:meta])* pub enum $enumname:ident { $($(#[$variantattr:meta])* : $enumvariantname:ident($ty:ty),)+ } ) => ( $(#[$attr])* pub enum $enumname { $($(#[$variantattr])* $enumvariantname($ty)),+ } $(impl From<$ty> for $enumname { fn from (ty: $ty) -> Self { $enumname::$enumvariantname(ty) } })+ ); ($(#[$attr:meta])* enum $enumname:ident { $($(#[$variantattr:meta])* : $enumvariantname:ident($ty:ty),)+ } ) => ( $(#[$attr])* enum $enumname { $($(#[$variantattr])* $enumvariantname($ty)),+ } $(impl From<$ty> for $enumname { fn from (ty: $ty) -> Self { $enumname::$enumvariantname(ty) } })+ ); }