4 releases
0.2.2 | Jan 12, 2025 |
---|---|
0.2.1 | Dec 21, 2024 |
0.2.0 | Dec 15, 2024 |
0.1.0 | Dec 15, 2024 |
#2 in #hot
1,970 downloads per month
Used in 4 crates
(via stak-module)
6KB
74 lines
hmr
Hot Module Reloading (HMR) for Rust.
Examples
use hmr::Module;
use std::fs::write;
use std::thread::sleep;
use std::time::Duration;
const PATH: &'static str = "test/foo.txt";
static FOO: Module = Module::new(PATH);
fn modify_file(content: &str) {
write(PATH, content).unwrap();
sleep(Duration::from_millis(100));
}
assert_eq!(&*FOO.load(), "foo\n".as_bytes());
modify_file("Hello, HMR!\n");
assert_eq!(&*FOO.load(), "Hello, HMR!\n".as_bytes());
modify_file("foo\n");
assert_eq!(&*FOO.load(), "foo\n".as_bytes());
License
Dependencies
~0.4–7MB
~43K SLoC