Skip to content
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

Option<T> methods should take T directly #11

Open
tqwewe opened this issue Apr 18, 2022 · 1 comment
Open

Option<T> methods should take T directly #11

tqwewe opened this issue Apr 18, 2022 · 1 comment

Comments

@tqwewe
Copy link
Contributor

tqwewe commented Apr 18, 2022

I'm using makeit heavily with props for a web framework, and currently when a prop is an Option<T>, you have to write <MyComponent prop={Some(val)} />, but it would be much more desireable in my case to do <MyComponent prop={val} />.

Could the set_ methods generated for fields of type Option<T> take T directly rather than the option itself?

If needed, another method set_none could be generated for options which would set it to None.

@tqwewe tqwewe closed this as completed Apr 19, 2022
@estebank estebank reopened this Apr 21, 2022
@mo8it
Copy link

mo8it commented Jun 4, 2023

@tqwewe This is possible in typed-builder using #[builder(default, setter(strip_option))]:

https://docs.rs/typed-builder/latest/typed_builder/derive.TypedBuilder.html#customisation-with-attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants