mixin StructParams!("S", int, "x", float, "y"); immutable S.WithDefaults combinedMain = { x: 12 }; // y is default-initialized immutable S.Func combinedDefault = { x: ()=>11, y: ()=>3.0 }; immutable combined = combine(combinedMain, combinedDefault); assert(combined.x == 12 && combined.y == 3.0);
Note that we cannot use struct literals like S.Regular(x: 11, y: 3.0) in the current version (v2.084.1) of D, just because current version of D does not have this feature. See DIP71.
Creates a "combined" structure from main and default_. The combined structure contains member values from main whenever !isNull for this value and otherwise calculated values from default_. Assertion error if both a member of main and of default_ are null.