3 ms·
Rust doesn't need to take the C++ approach to implement it, but it can still use the same syntax which is simply much neater. HashMap::from_array([[1, 2], [3, 4
by shmerl 11y ago
Rust doesn't need to take the C++ approach to implement it, but it can still use the same syntax which is simply much neater. HashMap::from_array([[1, 2], [3, 4]]) looks horrible in comparison.
Exact implementation is another question. That's why asked, whether it's feasible or it's something hard to fit into the language.
- dbaupp 11y agoI don't see how Rust can get the same syntax as C++ without having the implicit performance sink I mentioned: creating vectors and hashmaps needs to allocate, and so letting this happen implicitly is not great. In fact, the syntax was pretty much the whole meat of my comment.
- shmerl 11y agoWhy can't Rust do what it does already with macros, except using the simpler syntax described above? I.e. that syntax can mean explicit allocation (it's just a short form for it).