rksm / hot-lib-reloader-rs

Reload Rust code without app restarts. For faster feedback cycles.
MIT License
597 stars 19 forks source link

Including functions from multiple files is a bit tedious #24

Open filleduchaos opened 1 year ago

filleduchaos commented 1 year ago

The hot_functions_from_file! macro is very helpful, but it only works on single files (which most non-trivial projects grow out of quite quickly). If a user wants to break up their project into multiple files for manageability, their options are:

Both of these things are rather clumsy and would be unnecessary if hot_functions_from_file! didn't only work on single files. I took a look at the package source to see if there's any technical limitation preventing the macro from working on folders too but as far as I can tell, the only thing is that if a user uses the ignore_no_mangle option there is the possibility of duplicate function names in different files.

Proposal

Provide a new hot_functions_from_folder! or hot_functions_from_crate! macro that recursively pulls public no-mangled function definitions from a provided folder or crate path. Unlike hot_functions_from_file! it will not take an ignore_no_mangle argument, so that the function names/symbols are known to be unique.

I don't mind implementing it myself if you're good with this but that would have to be over the weekend.