-
Notifications
You must be signed in to change notification settings - Fork 52
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
Ensuring that at least one of a set of fields are set #6
Comments
I don't think the Rust type system is flexible enough to allow this... |
Actually... I was thinking about using marker traits, which are not stable yet, but instead I can use empty fields. Just set a field for each group and override its type when any member of the group is assigned. |
I recommend stealing from Something like this, on the struct (not on the field any more): #[builder(group = "a", required, any("bar", all("baz", not("quux"))))] This would define a named group “a” (the name is for documentation, and may also be used in other places that accept a field or group, such as field dependencies which I’m about to create an issue about). In this case the group is also then declared to be required before build() can be called. |
Recently started using this crate and quickly ran into a scenario that required something like this. Is anyone working on this? If not, is anyone able and willing to provide guidance on getting this implemented? |
See #14 and my algorithm https://codeberg.org/mo8it/sus-impls The macro has to use the algorithm to generate implementations |
It would be great if I could say something along the lines of:
Made up the syntax, but basically some way to signal "one or both of bar/baz must be provided".
The text was updated successfully, but these errors were encountered: