napi-rs/examples/napi/src/number.rs
2021-11-14 23:34:44 +00:00

12 lines
177 B
Rust

#[napi]
fn add(a: u32, b: u32) -> u32 {
a + b
}
#[napi(strict)]
fn fibonacci(n: u32) -> u32 {
match n {
1 | 2 => 1,
_ => fibonacci(n - 1) + fibonacci(n - 2),
}
}