[-] trurl 1 points 2 months ago

Getting metadata like this requires adding an extension to the language, either directly in code (as with a macro) or by messing with the build process (running another pass through your code to extract the metadata).

If you're not adverse to using a global, you could write a macro that you use instead of impl for these traits. So, for example:

register_plugin!(impl MyTrait for MyStruct {
  /* regular impl stuff goes here */
});

This macro would populate the global with metadata about the association between MyStruct and MyTrait. You could then pass a copy of it to AllFunctions::new.

Alternatively, write a macro that just does the registration, which is like what you're already doing:

impl MyTrait for MyStruct { ... }

register_plugin!(MyTrait, MyStruct);

Another option would be to write something funky in build.rs that does whatever rustdoc does to discover impls and pass that to the rest of your code as const data. As a hack, you could have it invoke rustdoc and then parse the output.

How dynamic is this plugin system, though? If you can only change the registered plugins by rebuilding, then automatic discovery doesn't seem so warranted. Invoking a simple registration macro at the bottom of each file would save a lot of complexity budget.

[-] trurl 1 points 1 year ago

It was the U.S. Robotics 56k PCI Winmodem that Dell was selling with their "Dimension XPS" Pentium II desktops. I later bought a proper 56k PCI modem off of a high school classmate so that I could download Debian packages without having to reboot into Windows first.

[-] trurl 2 points 1 year ago

Funny coincidence -- my wife has just gotten me to start following Legend of the Galactic Heroes. I'm reading the light novels (not much time for speed-running 45 hours of anime), and I also picked up the Vampire Hunter D novels.

She's said that there are a few active Discord communities for Legend of the Galactic Heroes. Are you aware of anything on the Fediverse?

trurl

joined 1 year ago