There was an interesting macro in that thread:
Click to see
#[doc(hidden)] pub use ::core;
#[macro_export]
macro_rules! FRU {(
$Struct:path {
$(
$field_name:ident : $value:expr,
)*
.. $($initial:expr)?
}
) => ({
let it = $crate::core::default::Default::default();
$(
let () = it;
let it = $initial;
)?
let mut it = it;
let $Struct { $($field_name: _,)* .. } = it; // ensure any DerefMut shenanigans are shadowed
$(
it.$field_name = $value;
)*
it
})}
which allows writing:
// Crate 2
fn main ()
{
let _options = FRU!(Options { bar: "baz".to_string(), .. /* default() */ });
}