enum-as-inner
A deriving proc-macro for generating functions to automatically give access to the inner members of enum.
Basic unnamed field case
The basic case is meant for single item enums, like:
extern crate enum_as_inner;
where the inner item can be retrieved with the as_*()
or with the into_*()
functions:
let one = One;
assert_eq!;
assert_eq!;
where the result is either a reference for inner items or a tuple containing the inner items.
Unit case
This will return copy's of the value of the unit variant, as isize
:
extern crate enum_as_inner;
These are not references:
let unit = Two;
assert_eq!;
Note that for unit enums there is no into_*()
function generated.
Mutliple, unnamed field case
This will return a tuple of the inner types:
extern crate enum_as_inner;
And can be accessed like:
let many = Three;
assert_eq!;
assert_eq!;
Multiple, named field case
This will return a tuple of the inner types, like the unnamed option:
extern crate enum_as_inner;
And can be accessed like:
let many = Three;
assert_eq!;
assert_eq!;