You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When implementing this, it breaks the defaulted version.
structStringSpark<T=BuildAlgorithmicIndexer>{ ... }StringSpark::default().spark(data);// doesn't compile because -> type annotations needed for `StringSpark<T>`
This is a known issue / design implementation in Rust, where StringSpark::default() does type inference without fallback to default types. There are work-arounds:
The difference is that in Type location the Rust compiler will use fill in type parameters, BUT in a Path expression everything will be inferred.
let _ = StringSpark::default();// StringSpark in path expression only, so defaults to StringSpark<_> which cannot be solved// Following is the same, SpringSpark is also in Type location. let _:StringSpark = StringSpark::default();let _:StringSpark<BuildAlgorithmicIndexer> = StringSpark::<_>::default();// This doesn't work because _ for T disables the default and uses inferencelet _:StringSpark<_> = StringSpark::default();// Using <SpringSpark> in a path expression will interpret SpringSpark within the brackets as a Typelet _ = <StringSpark>::default();// this works, as T will be replaced with defaultlet _ = <StringSpark<_>>::default();// Doesn't work as the inference replaces the default again.
Description
After implementation, something like this should work:
Links
The text was updated successfully, but these errors were encountered: