In Rust, we can create a Vector with macro vec![]
.
let numbers = vec![1, 2, 3];
Is there any similar macro that allow us to create a HashSet
?
From the doc https://doc.rust-lang.org/std/collections/struct.HashSet.html, I notice that we have HashSet::from
:
let viking_names = HashSet::from(["Einar", "Olaf", "Harald"]);
However, that requires us to create an array first, which seems a bit wasteful.