Crates.io | hmr |
lib.rs | hmr |
version | 0.2.5 |
created_at | 2024-12-15 11:23:19.149105+00 |
updated_at | 2025-09-20 04:27:47.626314+00 |
description | Hot Module Reploading for Rust |
homepage | |
repository | https://github.com/raviqqe/hmr |
max_upload_size | |
id | 1484071 |
size | 16,726 |
Hot Module Reloading (HMR) for Rust.
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());