Macro janetrs::janet_mod

source ·
macro_rules! janet_mod {
    ($mod_name:literal; $({$fn_name:literal, $fn:expr, $fn_doc:literal}),* $(,)?) => { ... };
}
👎Deprecated since 0.4.0: use declare_janet_mod instead
Expand description

A macro to make life easier creating modules for Janet from Rust.

§The syntax:

janet_mod!(<Janet Module Name (string literal)>; <{<Janet Function Name ((string literal))>, <function pointer>, <Janet documentation string (string literal)>}, ...>); ¹ Items inside <> means mandatory ² ... means one or more

§Examples

use janetrs::{janet_mod, Janet, janet_fn};

#[janet_fn(arity(fix(0)))]
fn rust_hello(args: &mut [Janet]) -> Janet {
    println!("Hello from Rust!");
    Janet::nil()
}

#[janet_fn(arity(fix(0)))]
fn hi(args: &mut [Janet]) -> Janet {
    Janet::from("Hi! My name is GrayJack!")
}

janet_mod!("rust";
    {"hello", rust_hello, "(rust/hello)\n\nRust say hello"},
    {"hi", hi, "(rust/hi)\n\nHi! My name is..."}
);