When calling a default implementation on a trait which does not take self
, why does it neeed an implementing type to be annotated?
A minimal, reproducible ex
This is not only a default implementation but the very specific case in which this default implementation does not even mention Self
/self
in its parameters, result and body.
I find much more easy to understand a rule saying that a type is required every time we use a trait, in any case, rather that « except if the default implementation does not even mention Self
/self
in its parameters, result and body ».
For this very specific use case, where you do not want to explicitly name a type when calling the function you need, I suggest using a free function.
mod builder {
// ...
pub fn make_default() -> Simple {
Simple
}
// ...
}
pub fn main() {
let _ = builder::make_default();
}