pub macro builtin(
$(#[$($meta:tt)*])*
fn $name:ident ($($arg:pat),*$(,)?) $(@$env:tt)? $body:block
) {
...
}
Expand description
Turns a function definition into a Builtin.
let my_builtin = builtin! {
/// Use the `@env` suffix to bind the environment!
/// (needed for recursive calls)
fn my_builtin(ConValue::Bool(b), rest @ ..) @env {
// This is all Rust code!
eprintln!("my_builtin({b}, ..)");
match rest {
[] => Ok(ConValue::Empty),
_ => my_builtin(env, rest), // Can be called as a normal function!
}
}
};