Based on the following examples, its possible to write a build-pattern with chained method calls in Rust which either passes by value or by reference (with a lifetime specifier)
- Is it possible to create a macro to implement builder pattern methods?
- How to overload the 'new' method? (top answer)
- https://github.com/rust-unofficial/patterns/blob/master/patterns/builder.md
A builder pattern in Rust may look something like this:
ui::Button::new()
.label("Test")
.align(Align::Center)
.build();
When writing idiomatic Rust is there a strong preference for one over another?
Is there some good example of how to write this in Rust?
ui.button(label="Test", align='CENTER')
style, so looking for something similar in Rust. – AceldamaButton { label = "Test", align = "CENTER", .. Default::default() }
syntax :) – LatishalatitudeButton { label: "Test", ....
? – Aceldama