Mastodon Feed: Post

Mastodon Feed

jsonstein@masto.deoan.org ("Jeff Sonstein") wrote:

two approaches to defining a thingie of type HashMap:

A) define before first use:

let mut scores: HashMap<String,i32> = HashMap::new();
[...]

B) define at first use:

let mut scores2 = HashMap::new();
[...]
scores2.insert(String::from("Yellow"), 10);
[...]

---

which do you prefer?
#LearningRust