Lets you derive Display
and Debug
traits by delegating them to the only member of 0..1
-member structs & enums.
```rust use delegate_display::{DelegateDebug, DelegateDisplay}; use core::fmt;
// Input
enum MyEnum { Foo, Bar(SomeType), Qux { baz: SomeType }, }
// Generated output
impl fmt::Display for MyEnum {
// Equivalent implementation for Debug & for structs
fn fmt(&self, f: &mut fmt::Formatter<'>) -> fmt::Result {
match self {
Self::Foo => f.writestr("Foo"),
Self::Bar(value) => fmt::Display::fmt(value, f),
Self::Qux { baz } => fmt::Display::fmt(baz, f),
}
}
}
```
See module-level documentation for more examples, what's allowed and what isn't.