4 ms·
In Rust in theory you could express each capability a collection can have as a trait, impl the relevant traits for each container type, then write generic code
by dataangel 5y ago
In Rust in theory you could express each capability a collection can have as a trait, impl the relevant traits for each container type, then write generic code that specifies it requires e.g. `NumberIndexable + FastAppend`. But AFAIK there is no way to ask the compiler to find the best available container type satisfying those traits; it would enforce anything you pass into the function satisfies them but wouldn't deduce it for you.
You could definitely do it with C++ template metaprogramming and type traits.