Intermediate Rust
Q99 / 100

What is the Entry API for HashMap in Rust?

Correct! Well done.

Incorrect.

The correct answer is B) A way to insert or modify a value only if the key is absent or present, avoiding redundant lookups via map.entry(key).or_insert(default)

B

Correct Answer

A way to insert or modify a value only if the key is absent or present, avoiding redundant lookups via map.entry(key).or_insert(default)

Explanation

counts.entry(word).and_modify(|c| *c += 1).or_insert(1) increments if present, inserts 1 if absent — all in one lookup.

Progress
99/100