json_args

Macro json_args 

Source
macro_rules! json_args {
    ($($arg:expr),*) => { ... };
}
Expand description

Map a series of values into a form which javascript functions can understand

Accepts a maximum of 16 arguments, of any combination of compatible types
For more than 16 arguments, use big_json_args! instead

NOTE: Since 0.6.0, this macro is now effectively a no-op
It simply builds a tuple reference from the provided arguments

You can also just pass a &tuple directly, or an &array, or even a single value

ยงExample

use rustyscript::{ Runtime, RuntimeOptions, Module, json_args };
use std::time::Duration;

let module = Module::new("test.js", "
    function load(a, b) {
        console.log(`Hello world: a=${a}, b=${b}`);
    }
    rustyscript.register_entrypoint(load);
");

Runtime::execute_module(
    &module, vec![],
    Default::default(),
    json_args!("test", 5)
)?;