-
Notifications
You must be signed in to change notification settings - Fork 66
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
Allow custom arbitrary methods for fields in the custom derive #33
Comments
No strong thoughts, we can allow multiple methods for overriding it perhaps. |
Is this still in the pipeline? Would significantly simplify my use case testing reasonably complex serde structures. |
AFAIK, no one has ever started implementing this. It seems like it is generally wanted/useful, so if you want to take a shot at implementing it, I would be happy to review/give feedback/etc. |
in cases where it's only the orphan rules prevent deriving Arbitrary, we could do a remote derive like serde does. I also like the idea of a function override as described before, and there's not full overlap |
I would love to have this. Otherwise it's almost impossible to apply Arbitrary in a big project, because there is always 2-3% of fields, that are not like others. |
FYI: I created ArbitraryExt crate which provides a temporal workaround for this problem. |
Would you like to turn that into a pull request for this crate? |
@fitzgen Sure. For now, |
This can be marked as resolved (since #129 is merged) |
Sometimes a field of a struct doesn't implement arbitrary and it is either impossible to do (because it is from another crate, for example) or undesired.
We should support some kind of attribute to either use the
Default::default
implementation for the type, when we "don't care" about that field, or supply an arbitrary function that has the same signature asArbitrary::arbitrary
to be used instead.This is all possible to do when implementing
Arbitrary
by hand, in the sense that you can always stuff whatever code inside the impl. But this seems common enough and simple enough that we may want to support it in the custom derive.Straw person syntax:
The open question in my mind is how to deal with the other, optional
Arbtirary
methods? e.g.arbitrary_take_rest
,shrink
, andsize_hint
. Should we assume the default implementations in this case? Should we also allow providing custom implementations for them?Any thoughts @Manishearth?
+cc @bnjbvr
The text was updated successfully, but these errors were encountered: