Skip to content

Feature request: Add Index<usize> to Keys #284

Closed
@jrose-signal

Description

@jrose-signal

#132 added usize-based indexing for the values in an IndexMap, which is absolutely the correct behavior for Index<usize> to have. However, sometimes I want to get either just the key or a key-value pair at a particular index, and get_index is a verbose way to do that if I know the index is valid. A possible alternate spelling would be map.keys()[idx], implemented by providing Index<usize> on Keys.

Of course, this particular approach means that indexing would be valid even after consuming some of the keys, even if that's not the recommended use, and the code needs to decide and document what that means.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions