Macro janetrs::declare_janet_mod
source · declare_janet_mod!() { /* proc-macro */ }
Expand description
Declare a Janet module.
This macro can detect and get the documentation from the function, so you just need to pass the function name for Janet and the identifier of the native function.
§Examples
ⓘ
use janetrs::{janet_mod, Janet, janet_fn};
/// (rust/hello)
///
/// Rust says hello to you! 🦀
#[janet_fn(arity(fix(0)))]
fn rust_hello(args: &mut [Janet]) -> Janet {
println!("Hello from Rust!");
Janet::nil()
}
/// (rust/hi)
///
/// I introducing myself to you! 🙆
#[janet_fn(arity(fix(0)))]
fn hi(args: &mut [Janet]) -> Janet {
Janet::from("Hi! My name is GrayJack!")
}
#[janet_fn(arity(fix(0)))]
fn no_doc_fn(args: &mut [Janet]) -> Janet {
Janet::nil()
}
declare_janet_mod!("rust";
{"hello", rust_hello},
{"hi", hi},
{"no_doc_fn", no_doc_fn, "Using custom docs as string literal"},
);