Struct initialization using partial destructuring

Is there a clean way to achieve something like this:

let abcd = ABCD {
    field_1 = fn_1(),
    field_2 = fn_2(),
    ...
    [field_m, ..., field_n] = fn_m_n(),
    ...
    field_o = fn_o()
};

Assuming that initialization functions must be called in order.

Right now i'm stuck with a lot of boilerplate:

let field_1 = fn_1();
let field_2 = fn_2();
...
let [field_m, ..., field_n] =  fn_m_n();

let abcd = ABCD {
    field_1,
    field_2,
    ...
    field_m,
    ...
    field_n,
    ...
    field_o = fn_o()
};

I'm open to nightly features (I looked into destructuring_assignment but this isn't quite what i need).

Unfortunately, no. If you really have a lot of these, you might consider writing a macro.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.