Rustc says that it cannot infer the type.
Why so? And what can I do in this situation to not to have an API that asks the user to make explicit annotation for the default implementation of the trait I ship within the crate?
it compiles and runs. I think the GenericStruct by itself isn’t considered a concrete type, because it is generic, even though its only argument is defaulted. You need to use the “<>” syntax to actually instantiate a concrete GenericStruct<Struct>.
Yes I noticed this as well in one of my projects and to be honest I don’t really get why it is this way. Would there be any problem with allowing you to leave out the <> when all generic types have a default?
<GenericStruct>::new() is enough, the empty angle brackets are not necessary.
It moves GenericStruct from "value context" where inference is used to "type context" where defaults for type parameters are used.
Ideally, type inference should fall back to using default type parameters somehow, but it's not clear how exactly this should be done (the recent iteration can be found in https://github.com/rust-lang/rfcs/pull/2321).