Elektrine lite

← Feed

@argv_minus_one@mastodon.sdf.org

Post #2489042

2025-05-21 22:02 UTC

@rain@hachyderm.io Ooh neat. I was wanting something like this for years. I would have preferred if the map takes a function to extract the key from the value, though, rather than requiring the value to implement a trait. Then I could, for example, index `User`s by both `name` and `age` (as separate `IdHashMap`s), which unless I'm mistaken would be difficult with this trait-based design.

Replies (2)

  • @rain@hachyderm.io 2025-05-21 22:04

    @argv_minus_one@mastodon.sdf.org Definitely something I considered, but the API got too unwieldy, it's already complex enough. You can use a newtype though!

    Open ##2489043

  • @zbrown@floss.social 2025-05-22 03:18

    @argv_minus_one@mastodon.sdf.org @rain@hachyderm.io yeah I've totally had cases for this, now the question is will I remember it for next time 🙈

    Open ##2489044