#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

#2 in #hot

Download history 197/week @ 2024-12-11 642/week @ 2024-12-18 254/week @ 2024-12-25 347/week @ 2025-01-01 848/week @ 2025-01-08 389/week @ 2025-01-15 373/week @ 2025-01-22

1,970 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–7MB
~43K SLoC