You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just started using this crate today and love it.
The only thing I wish it had is a way to define the setter function for specific fields.
For instance I have a data type in a struct that I need to transform before setting that can't easily be converted using Into, or even From, since they have default implementations and specialization is not in the language yet.
I decoded what I needed to do from this repo, but It would be nice to override this behavior in a nicer way
structA{a:some_type}structAWrapper(A);#[derive(TypedBuilder)]structB{z:u64,a:A,b:usize,}// here's what I created to override the behaviorimplBBuilder<((u64,),(),(usize,))>{pubfnwith_a(self,a:&AWrapper,) -> BBuilder<((u64,),(A,),(usize,))>{let(z, _, b) = self.fields;let a = (a.0,);BBuilder{fields:(z, a, b),_phantom:self._phantom,}}
This is pretty cumbersome, and only works in when part of the Builder has already been created.
I've looked around other issues, and this seems similar to skip, however I would rather it failed compiling because there was no method that replaces it.
The text was updated successfully, but these errors were encountered:
#23 is a big and complex feature, and something like this would be quicker and easier to implement - and we'll still want it even after we have #23. The idea is that with_a only exists in the builder type, and a only exists in the actual type. So the user sets with_a using a normal setter, and it remains there for the lifetime of the builder, but does not get copied to B. Instead, a's default uses the value fromwith_a to construct a - which gets skipped and doesn't get its own setter.
I just started using this crate today and love it.
The only thing I wish it had is a way to define the setter function for specific fields.
For instance I have a data type in a struct that I need to transform before setting that can't easily be converted using Into, or even From, since they have default implementations and specialization is not in the language yet.
I decoded what I needed to do from this repo, but It would be nice to override this behavior in a nicer way
This is pretty cumbersome, and only works in when part of the Builder has already been created.
I've looked around other issues, and this seems similar to
skip
, however I would rather it failed compiling because there was no method that replaces it.The text was updated successfully, but these errors were encountered: