Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You end up having to do

  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.


It's a lot of small papercuts, but

    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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: