-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
By "strict" I mean ones that panic on duplicate keys/items.
The rationale has to do mostly with hashmaps that serve as "registries" of some sort. In my project, for example, there is a hashmap! of supported remote services where each one should have a unique textual identifier. As their number grows, I've became somewhat concerned about accidental name clashes.
Something like hashmap_strict! would helpful in catching these kinds of problems. It doesn't have to be fancy at all; a simple hashmap.insert(k, v).and_then(|_| panic!("duplicate hashmap key: {:?}")); would be sufficient (and the Debug requirement for keys is in line with panicking functions in stdlib, e.g. expect).
cpick
Metadata
Metadata
Assignees
Labels
No labels