This solution works sometimes, but it's not great if any of the fields don't have a sensible default.
struct Parameters {
non_optional_parameter_1: Foo,
non_optional_parameter_2: Bar,
extra_options: ParametersWithDefault,
}
#[derive(Default)]
struct ParametersWithDefault {
...
}
which is kind of annoying but not the end of the world. use module::{ foo, Parameters, ParametersWithDefault };
fn bar() {
foo(Parameters {
non_optional_parameter_1: Foo,
non_optional_parameter_2: Bar,
extra_options: ParametersWithDefault {
optional_param: Baz,
...Default::default(),
}
});
}
is a far cry in ergonomics from: use module::foo;
fn bar() {
foo(_ {
non_optional_parameter_1: Foo,
non_optional_parameter_2: Bar,
optional_param: Baz,
..
});
}
Even just having to import the extra structs (and lookup the names) is a massive pain. Especially if you need to change to use a slightly different function.