ref: https://www.thecodedmessage.com/posts/default-params/
Sol 1
1impl Default for WindowConfig {2 fn default() -> Self {3 Self {4 width: 100,5 height: 100,6 visibility: WindowVisibility::Visible,7 window_style: WindowStyle::Standard,8 z_position: -1,9 autoclose: AutoclosePolicy::Disable,10 }11 }12}13
14let handle = create_window(WindowConfig {15 width: 500,4 collapsed lines
16 z_position: 2,17 autoclose: AutoclosePolicy::Enable,18 ..Default::default()19});Sol 2..
1impl WindowBuilder {2 fn height(mut self, height: u32) -> Self {3 self.height = height;4 self5 }6
7 // ...8}9
10impl WindowBuilder {11 fn height(self, height: u32) -> Self {12 Self {13 height,14 ..self15 }29 collapsed lines
16 }17
18 // ...19}20
21impl WindowBuilder {22 fn autoclose_enable(mut self) -> Self {23 self.autoclose = AutoclosePolicy::Enable;24 self25 }26
27 fn autoclose_disable(mut self) -> Self {28 self.autoclose = AutoclosePolicy::Disable;29 self30 }31}32
33impl WindowBuilder {34 fn build(self) {35 window_create(self)36 }37}38
39
40let handle = WindowBuilder::new()41 .width(500)42 .z_position(2)43 .autoclose_enable()44 .build();