Vec has a macro to assist in initialising a Vec with given contents, however none of the other collections in libstd have one. Many other languages have syntax for declaring e.g. a hash map in one go, including Python, Ruby, C++, and C#. Could we do something similar for at least the more commonly used collections, such as HashMap (and maybe others)?
I was thinking along these lines:
let my_vec = vec![1, 2, 3]; // this is for Vec
let my_hashmap = hashmap!{“one”: 1, “two”: 2, “three”: 3}; // this is for HashMap
I’m not sure if this syntax is possible, but I assume it is as vec! has square brackets instead of parentheses. What are your thoughts? Any other collections this could be useful for?