LPGhatguy / thunderdome

Arena type inspired by generational-arena
Apache License 2.0
197 stars 15 forks source link

Consider exposing generation #34

Closed shepmaster closed 2 years ago

shepmaster commented 2 years ago

I have a few thunderdome::Arenas so I'm wrapping the Index in my own newtypes to keep things manageable. That means that my Debug output looks like:

ElementIndex(Index { slot: 1, generation: Generation(2) })

I'd prefer to use something a bit shorter:

ElementIndex(2, 1)

However, it's not possible to get the generation out of an Index for use in my own Debug implementation. I assume there's good reasons for that, so this suggestion may go nowhere, but it's worth asking!

LPGhatguy commented 2 years ago

I don't see why not! We could probably add a generation(&self) method to return the generation, probably no harm in doing so.

shepmaster commented 2 years ago

it's not possible to get the generation out of an Index

I guess this isn't technically true, as I could use Index::to_bits and extract the generation; that seems like reasonable justification that it could stand as a separate method.