Currently I find myself using std::default::Default::default()
in any Rust program I write, probably because it is such a common thing to do.
Something that irritates me is that I can derive structures from some built-in Default
trait, but must explicitly import the trait with use std::default::Default
to actually instantiate such a struct
with it. This feels unintuitive to me, especially considering that I can do the same with the Clone
trait, without having to explicitly use
it though.
My initial thinking was to propose adding std::default::Default
to the prelude, but that was before I have read this topic about initialising structures. It hinted at the possibility to either add the Default
trait to the prelude, or even have a default()
function that does the same.
Can someone point me to the source of this discussion ? Maybe there is an RFC I don’t know about.
Thank you