In Rust, it is no possible to define default values in methods and
functions. This implies that in a constructor method we cannot make
optional the setting of certain fields. To be able to set default values
to fields and still allow the user to easily set his/her own values
while building a new object, we need another mechanism called Builder
Setters. The convention in Rust is to name those methods using the
with_ prefix. The idea is to chain one more with_...() methods after
the call to the constructor new(). Each method takes ownership of the
object, modifies it and returns it.
Example:
let color = Color::new(0x00, 0xff, 0x50)
.with_transparency(60)
.with_blinking(true);