Skip to content

Make API less surprising by unifying new and with_key? #146

@grothesque

Description

@grothesque

In light of a possible 2.0 version of this crate, would it be possible to unify the constructors new and with_key of SlotMap into a single new constructor?

In my understanding, the convention for with_ constructors is that they take additional parameters (e.g. Vec::with_capacity). But here with_key implies something about the type of the collection. In addition, it is confusing that SlotMap with a key type different from the default does not offer a new default constructor.

One way to resolve both issues would be to make DefaultKey the default for the first generic argument of the SlotMap type. Wouldn’t this result in a less surprising API?

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