Add Indexer trait implementation built with rangemap
ekroon opened this issue · comments
Description
After implementation, something like this should work:
StringSpark::<BuildRangemapIndexer>::default().spark(data)
Links
When implementing this, it breaks the defaulted version.
struct StringSpark<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:
<StringSpark>::default().spark(data);
let s: StringSpark = StringSpark::default();
s.spark(data);
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 inference
let _: StringSpark<_> = StringSpark::default();
// Using <SpringSpark> in a path expression will interpret SpringSpark within the brackets as a Type
let _ = <StringSpark>::default(); // this works, as T will be replaced with default
let _ = <StringSpark<_>>::default(); // Doesn't work as the inference replaces the default again.