mcarton / rust-derivative

A set of alternative `derive` attributes for Rust
Apache License 2.0
422 stars 46 forks source link

feature request: default on Clone #108

Open bryanlarsen opened 1 year ago

bryanlarsen commented 1 year ago

problem:

I have a struct that needs to be Clone. It contains a member foo with type Option where Foo isn't Clone. On clone I'd like foo to be None (aka Option::default()).

Having used derivative on Debug in the past to do similar things, and having used default in serde, I expected that derivative would let me do this easily.

feature request:

add a field attribute "default" for Clone, with the same behavior as serde's default: https://serde.rs/attr-default.html