Macro derive_deftly_template_ExtendBuilder

Source
macro_rules! derive_deftly_template_ExtendBuilder {
    ({ $($driver:tt)* } [$($aoptions:tt)*] ($($future:tt)*) $($tpassthrough:tt)*) => { ... };
    ($($wrong:tt)*) => { ... };
}
Expand description

Provide an ExtendBuilder implementation for a struct’s builder.

This template is only sensible when used alongside #[derive(Builder)].

The provided extend_from function will behave as:

  • For every non-sub_builder field, if there is a value set in other, replace the value in self (if any) with that value. (Otherwise, leave the value in self as it is).
  • For every sub_builder field, recursively use extend_from to extend that builder from the corresponding builder in other.

§Interaction with sub_builder.

When a field in the struct is tagged with #[builder(sub_builder)], you must also tag the same field with #[deftly(extend_builder(sub_builder))]; otherwise, compilation will fail.

§Interaction with strip_option and default.

The flags have no special effect on the ExtendBuilder, and will work fine.

(See comments in the code for details about why, and what this means. Remember, builder(default) is applied when build() is called, and does not automatically cause an un-set option to count as set.)

This is a derive_deftly template. Do not invoke it directly. To use it, write: #[derive(Deftly)] #[derive_deftly(ExtendBuilder)].