linkme (also mentioned upthread) by the same author provides literally the distributed slice of statics, using linker shenanigans.
TL;DR what it does:
- name a new linker section
- put known zero-sized names at the beginning and end of the section
- distributed slice members are statics located in the new section
- create a slice from the start marker to the end marker
If you only care about platforms with linker support for doing that, linkme works perfectly. The maintainer(s) explicitly welcome PRs to support more platforms; they just don't have reason themselves to add support for other platforms they don't know as well.
Obviously compiler support would eliminate the need for linker support (and mean support for wasm?), so it's still better than adhoc linker shenanigans. But people undersell linkme, which is mostly supposed to replace inventory for the distributed slice use case.
(Side note: the compiler already has distributed slice like support for #[test_case]
, though it is specialized for that one specific use case.)