lesurp / OptionalStruct

Macro copying a struct with Option fields. Useful for config initialization
Apache License 2.0
36 stars 13 forks source link

Change Option<> fields behavior #18

Closed eliad-wiz closed 10 months ago

eliad-wiz commented 1 year ago

Currently there's a specialized behavior for Option<> fields - they are being overridden even if the applied field is none.

This is counter-intuitive, and doesn't make much sense (at least for me).

Remove the specialized behavior and make it behave similarly to any other field.

Note that this is a breaking change, so a further version bump is required.

lesurp commented 10 months ago

This is now doable by using the #[optional_wrap] attribute on the Option you want to wrap (see tests/wrap_option.rs)

I'm not sure what is the preferred behavior. On one hand, I think my approach is the more 'useful' one, on the other hand, having special cases (even for standard types) should be avoided.

Anyway, feel free to open an issue if you believe this is not solving your problem. Thanks for taking the time to contribute!