rust-typed-builder icon indicating copy to clipboard operation
rust-typed-builder copied to clipboard

Ensuring that at least one of a set of fields are set

Open insanitybit opened this issue 5 years ago • 5 comments

It would be great if I could say something along the lines of:

#[derive(TypedBuilder)]
struct Foo {
    #[group(a)]
    #[default]
    bar: Option<String>,
    #[group(a)]
    #[default]
    baz: Option<String>,
    #[default]
    bat: Option<String>,
}

Made up the syntax, but basically some way to signal "one or both of bar/baz must be provided".

insanitybit avatar Nov 09 '18 05:11 insanitybit