Macro rustler_codegen::init
source · [−]init!() { /* proc-macro */ }
Expand description
Implementation of a Native Implemented Function (NIF) macro that lets the user annotate a function that will be wrapped in higer-level NIF implementation.
ⓘ
#[rustler::nif]
fn add(a: i64, b: i64) -> i64 {
a + b
}
#[rustler::nif]
fn sub(a: i64, b: i64) -> i64 {
a - b
}
#[rustler::nif]
fn mul(a: i64, b: i64) -> i64 {
a * b
}
#[rustler::nif]
fn div(a: i64, b: i64) -> i64 {
a / b
}
rustler::init!("Elixir.Math", [add, sub, mul, div], Some(load));