This is a "pie in the sky" question. I don't think it's possible, and I don't even really know how to ask the question. But I'm hoping that someone may have an answer, or an alternative way of doing the same thing.
I have a number of structs that I wanted to define decoratively, and they each have a lot of boiler plate. So, I have a combination of a derive macro and a couple attribute macros that do the work for me.
is expanded out to a struct that implements a couple custom traits and fleshes out a few custom methods. All that works well.
What I'd like to be able to do is -- at build or compile time -- collect information about all of these instructions and create some rust structure somewhere else after all have been expanded.
So, I would end up with (for instance) an enum in a different module with a variant for each instruction.
I have (sorta) gotten this to work with a crappy python script, but I was hoping there is a way to leverage macros. Or build scripts.
Any thoughts would be greatly appreciated. And, I can share more code if that's helpful. I just didn't want to overwhelm the topic with code that is currently working.
Looks like there's a link-time solution, like Linkme — Rust build util // Lib.rs. Will be interesting to hear if there's anything compile-time, though!
I really appreciate the conversation. It seems like there is no production-safe way of doing what I'm wanting, but I was able to get the GitHub - dtolnay/linkme: Safe cross-platform linker shenanigans crate working in such a way as to do what I wanted. Since the project I'm working on is really an experiment, I'm comfortable using it for now.
@MichaelV I couldn't see any documentation about why they were archived. What is the bug?
I know that the crate works for my toy example, but I fear that it will explode. So I guess I should blog about my personal solution to this problem space
If I would have time ...
The linkme solution actually works really well (so far). I was even able to add the distributed_slice into the existing procedural macro. I haven't hit the reported issue, but needless to say I don't think I would want to use this for anything other than this research experiment.