#module #hot #reploading

hmr

Hot Module Reploading for Rust

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

#3 in #hot

Download history 123/week @ 2024-12-09 626/week @ 2024-12-16 270/week @ 2024-12-23 216/week @ 2024-12-30 835/week @ 2025-01-06 456/week @ 2025-01-13 379/week @ 2025-01-20 209/week @ 2025-01-27

1,914 downloads per month
Used in 4 crates (via stak-module)

Custom license

6KB
74 lines

hmr

GitHub Action Crate License

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

MIT

Dependencies

~0.4–7.5MB
~50K SLoC