mirror of
https://github.com/napi-rs/napi-rs.git
synced 2025-12-08 19:56:07 +00:00
chore: remove lifetime param in example
This commit is contained in:
parent
0a388056ad
commit
f751ea3b2a
@ -29,7 +29,7 @@ One nice feature is that this crate allows you to build add-ons purely with the
|
||||
## Taste
|
||||
```rust
|
||||
#[js_function(1)] // ------> arguments length, omit for zero
|
||||
fn fibonacci<'env>(ctx: CallContext<'env>) -> Result<Value<'env, Number>> {
|
||||
fn fibonacci(ctx: CallContext) -> Result<Value<Number>> {
|
||||
let n = ctx.get::<Number>(0)?.try_into()?;
|
||||
ctx.env.create_int64(fibonacci_native(n))
|
||||
}
|
||||
|
||||
@ -19,12 +19,12 @@ fn init<'env>(
|
||||
}
|
||||
|
||||
#[js_function]
|
||||
fn test_throw<'a>(_ctx: CallContext) -> Result<Value<'a, Any>> {
|
||||
fn test_throw(_ctx: CallContext) -> Result<Value<Any>> {
|
||||
Err(Error::new(Status::GenericFailure))
|
||||
}
|
||||
|
||||
#[js_function(1)]
|
||||
fn fibonacci<'env>(ctx: CallContext<'env>) -> Result<Value<'env, Number>> {
|
||||
fn fibonacci(ctx: CallContext) -> Result<Value<Number>> {
|
||||
let n = ctx.get::<Number>(0)?.try_into()?;
|
||||
ctx.env.create_int64(fibonacci_native(n))
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ use napi_rs::{Result, Value, CallContext, Number};
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[js_function(1)]
|
||||
fn fibonacci<'env>(ctx: CallContext<'env>) -> Result<Value<'env, Number>> {
|
||||
fn fibonacci(ctx: CallContext) -> Result<Value<Number>> {
|
||||
let n = ctx.get::<Number>(0)?.try_into()?;
|
||||
ctx.env.create_int64(fibonacci_native(n))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user