Finally - this feels like breaking the Rust rule that the information about the types should be in the signatures, not in the implementation body. And yes, you can argue that the attributes are part of the signature, but #[builder(default)] acts as an implementing code generator and it feels wrong to have it affect the signature...
I totally agree with your assessment here. Specifying the default type for generic parameters in order to enable this feature feels like a happy medium since it keeps all the default type information in the struct signature.
I also added some tests and examples which show how this new feature interacts with more complex types that use both generic parameters with and without defaults. The code might not be the cleanest at the moment, just wanted to get a working model up first and then can refactor as needed. Let me know what you think!
Closes #44
This would support the example in #44
if and only if a default generic type is specified for
T
like sohttps://github.com/idanarye/rust-typed-builder/issues/44#issuecomment-761195682
I totally agree with your assessment here. Specifying the default type for generic parameters in order to enable this feature feels like a happy medium since it keeps all the default type information in the struct signature.
I also added some tests and examples which show how this new feature interacts with more complex types that use both generic parameters with and without defaults. The code might not be the cleanest at the moment, just wanted to get a working model up first and then can refactor as needed. Let me know what you think!