hmr 0.2.5

Hot Module Reploading for Rust
Documentation

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