postscriptum 0.1.1

Multi-interpreted-language scripting engine for Rust with Rhai and Python backends
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! Minimal example: evaluate a Rhai script and call a Rust function
//! registered through a `FunctionBundle`.

use postscriptum::{EngineType, FunctionBundle, get_engine_with_bundle};

fn main() -> postscriptum::Result<()> {
    let mut bundle = FunctionBundle::new(EngineType::Rhai);
    bundle.add_rhai_fn1::<fn(i64) -> i64, i64, i64>("double", |x: i64| x * 2);

    let mut engine = get_engine_with_bundle(EngineType::Rhai, &bundle);
    println!("double(21) = {}", engine.eval("double(21)")?);
    Ok(())
}