Link: small_type_id
I was wanting to have some compile time TypeIds so I can run const assertions in my ECS engine.
While working on it, I thought that it may be useful for other developers so I released it as a separate crate.
Features:
TYPE_ID
is a constant (vs runtime only in std).- Size is 32 bit (vs unspecified 16 bytes in std).
TypeId
cannot be zero which allows niche optimizations- Most significant bit is guaranteed to be zero to allow users mix it with another 32 bit ids (e.g. using union).
- Uniqueness of ids are checked in runtime before
main
by usingctor
crate + linker section tricks.
Also, I take effort to make crate not dependent from quote, syn and proc_macro2 because I find bottlenecking on them during compilation of large projects slightly annoying.
Hopefully, it would be useful.