Macro Unwrap
macro_rules! Unwrap { ... }
What #[derive(Unwrap)] generates
When an enum is decorated with #[derive(Unwrap)], for each variant foo in the enum, with fields (a, b, c, ...) a public instance method unwrap_foo(self) -> (a, b, c, ...) is generated.
If you don't want the unwrap_foo method generated for a variant, you can put the #[unwrap(ignore)] attribute on that variant.
If you want to treat a reference, you can put the #[unwrap(ref)] attribute on the enum declaration or that variant, then unwrap_foo_ref(self) -> (&a, &b, &c, ...) will be generated. You can also use mutable references by putting #[unwrap(ref_mut)].
Example usage
# use Unwrap;
#
#
What is generated?
The derive in the above example code generates the following code:
#
#