No. Rust doesn’t have runtime type information, and the type information it does have at compile time can’t be accessed in any way from your code.
More edits: OK, OK… I mean, you can introspect types, but that requires a lint, which is a compiler plugin, which means the interface is effectively unsupported and changes on a regular basis. Also, lints can’t generate code, so you’d have to pull some TeX shenanigans to use that information.
What you could do is write a custom derive that you add to each type that implements
X, and write those out to a file, which you then re-import on the next compile to generate
all_x… but again, yuck.
Or, if you’re super desperate, you could use
syn in a build script to parse your source code, find all the implementations of
X (keeping in mind that you don’t have access to name or type resolution), and generate
all_x that way.
But, honestly, I’d just write
all_x by hand.