The IntegerId trait currently requires the type to be Copy, which reduces flexibility for a key type used in an idmap.
The current implementation of DirectIdMap does not actually store keys, meaning it needs to summon keys from the integer index.
One potential solution is to require a separate IntegerKey trait for idmaps. There can be a blanket implementation for IntegerId that stores a ZST but also allows owned keys that need a real value to be stored.
I ran into this problem working on switching dropping-thread-local from a hashmap to an idmap. Key types are reference counted to avoid freeing keys currently in use, which means keys must be !Copy.
The
IntegerIdtrait currently requires the type to beCopy, which reduces flexibility for a key type used in an idmap.The current implementation of
DirectIdMapdoes not actually store keys, meaning it needs to summon keys from the integer index.One potential solution is to require a separate
IntegerKeytrait for idmaps. There can be a blanket implementation forIntegerIdthat stores a ZST but also allows owned keys that need a real value to be stored.I ran into this problem working on switching
dropping-thread-localfrom a hashmap to an idmap. Key types are reference counted to avoid freeing keys currently in use, which means keys must be!Copy.