mun_runtime 0.3.0

A runtime for hot reloading and invoking Mun from Rust
Documentation
use mun_runtime::{invoke_fn, RuntimeBuilder};
use std::env;

// How to run?
// 1. On the CLI, navigate to the `crates/mun_runtime/examples` directory.
// 2. Run the compiler daemon from the CLI: `/path/to/mun build resources/fibonacci.mun --watch`
// 3. Run the application from the CLI: cargo run --example fibonacci -- fibonacci.munlib
fn main() {
    let lib_dir = env::args().nth(1).expect("Expected path to a Mun library.");
    println!("lib: {}", lib_dir);

    let runtime = RuntimeBuilder::new(lib_dir)
        .spawn()
        .expect("Failed to spawn Runtime");

    let mut runtime_ref = runtime.borrow_mut();

    loop {
        let n: i64 = invoke_fn!(runtime_ref, "nth").unwrap_or_else(|e| e.wait(&mut runtime_ref));
        let result: i64 =
            invoke_fn!(runtime_ref, "fibonacci", n).unwrap_or_else(|e| e.wait(&mut runtime_ref));
        println!("fibonacci({}) = {}", n, result);
        runtime_ref.update();
    }
}