Skip to content

Strict versions of the macros #16

@Xion

Description

@Xion

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions