-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic Setter #30
Comments
This is very interesting! I do worry this kind of API is outside the scope of this library (this focuses on trivial getters and setters, and these kinds of calls would introduce implicit cloning). These kinds of calls have real performance implications. That said, if this could be done unobtrusively (without breaking changes) in a way that was easy to understand, I'd be willing to accept a PR. :) |
I tend to use this patterns a lot too |
#49 may require us to rethink the proposed syntax here! |
Maybe you can take some inspiration from here https://github.com/Luro02/shorthand My syntax looks like this #[shorthand(enable(into))]
// or
#[shorthand(disable(into))] https://docs.rs/shorthand/0.1.0/shorthand/derive.ShortHand.html#into |
For example
would generate
It'd be nice to have something like this generated instead
this would allow the user to set more, than just String like
&str
,&String
orCow<'_, str>
.Maybe this could be enable by adding
#[setter(into)]
to the structFor reference: derive_builder
The text was updated successfully, but these errors were encountered: