I find hot-reloading a very useful feature that speeds up development and makes debugging easier. I use it extensively in C#, and I wanted to have the same feature in Rust, so I created a crate for it: hotcode.
It provides a single attribute, #[hotreload], that can be applied to any function in a [lib] crate. It makes annotated functions hot-reloadable:
use hotcode::hotreload;
#[hotreload]
fn get() -> i32 { 1 }
impl Struct {
#[hotreload]
fn get(&self) -> i32 { self.value }
}
impl Trait for Struct {
#[hotreload]
fn get(&self) -> i32 { self.value + 1 }
}
Your library crate must also be built as both a cdylib and an rlib:
[lib]
crate-type = ["cdylib", "rlib"]
You can now run your application and make changes to your library without restarting it. hotcode will automatically apply those changes.
Here's a usage example - a rasterization function being hot-reloaded in a software renderer:
https://raw.githubusercontent.com/alordash/hotcode/cc33cf97e0f1d53db0105504b3e1a10a5eee60f2/media/hotreload_renderust.mp4
hotcode works by swapping dynamic libraries from a separate file-watcher thread - the same principle that has been used by other hot-reloading libraries, such as hot-lib-reloader-rs and rust-hot-reloading. This approach was also explained in this blogpost.
Source repository: GitHub - alordash/hotcode: Library for hotreload in Rust · GitHub
Crate documentation: hotcode - Rust
I hope this helps someone speed up their development iterations!
2 posts - 1 participant
Read full topic
| # | Наименование новости | Тональность | Информативность | Дата публикации |
|---|---|---|---|---|
| 1 | Zaxis 0.0.5: immediate-mode GUI on wgpu, embeddable in a host's wgpu pass, with an real overlay layer for other processes | 0 | 10.2 | 11-10-2026 |
| 2 | FerroProve - C-to-Rust lifter emitting #![forbid(unsafe_code)] crates with a differential oracle | 0 | 15.51 | 17-10-2026 |
| 3 | Maplike - Crate with traits for abstract containers and operations on them | 2 | 7 | 06-07-2026 |
| 4 | [Project] sol: A self-contained browser kernel written in Rust | 0 | 9.76 | 18-10-2026 |
| 5 | I made a Vibe-Coded Reusable Application Runtime For Any Digital Domain (Office apps, Digital Painter, Graph nodes based apps..etc) | 0 | 17.83 | 12-10-2026 |
| 6 | Multi_bimap - many-to-many bimap freely made of two arbitrary maps | 0 | 13.1 | 16-10-2026 |
| 7 | Cargo-Rail v0.20: one workspace engine instead of dependency, CI, cache, release, and split-repo glue/plugins | 0 | 10.4 | 30-07-2026 |
| 8 | My state lib PurrGress | 0 | 12.62 | 13-08-2026 |
| 9 | I wrote my M.Sc. thesis on using the Rust type system in 3D graphics | 0 | 7 | 29-06-2026 |