Inline Default
A macro for implementing Default
within a struct definition.
For example,
use inline_default;
inline_default!
expands to
Supports:
- Visibility specifiers
- Use Default if not specified
- Attributes (including derives)
- Lifetimes
- Generics, with major caveats
Due to the complexity in parsing trait bounds,
only a single trait bound without generics is accepted.
where
clauses are not supported.
Specifying lifetimes are accepted, but not the 'outlives' syntax 'a: 'b
.
For example,
use inline_default;
inline_default!
is accepted, but the following are not:
use inline_default;
// NOT VALID
inline_default!
// NOT VALID
inline_default!
// NOT VALID
inline_default!
Proc Macro?
Making a proc macro would be fuller feature-wise, but I couldn't be bothered.