And then there's this crate https://docs.rs/live-reload/0.2.0/live_reload/ which works on the same principles as the article above, and is based on C code (i.e. the same approach works for C). On the documentation there's links to "Interactive Programming in C" http://nullprogram.com/blog/2014/12/23/ and "Loading Game Code Dynamically" https://www.youtube.com/watch?v=WMSBRk5WG58 (this video by Casey Muratori is btw where I first heard about this technique)
There's a bunch of other libraries that work the same way, and some example code that can do this. I can find https://github.com/irh/rust-hot-reloading and https://github.com/porglezomp-misc/live-reloading-rs and https://github.com/xixixao/hot-reload-rs and https://github.com/emoon/dynamic_reload
And there's https://github.com/draivin/rust-hotswap which has a nice API but uses a deprecated rustc internal API and doesn't build anymore.
Anyway there was a library that did this in a more elegant way and I just can't find it (perhaps it was rust-hotswap?).
https://github.com/ziglang/zig/issues/68
That issue has some links to people doing it in C/C++.