chore: remove lifetime param in example
This commit is contained in:
parent
0a388056ad
commit
f751ea3b2a
3 changed files with 4 additions and 4 deletions
|
@ -29,7 +29,7 @@ One nice feature is that this crate allows you to build add-ons purely with the
|
||||||
## Taste
|
## Taste
|
||||||
```rust
|
```rust
|
||||||
#[js_function(1)] // ------> arguments length, omit for zero
|
#[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()?;
|
let n = ctx.get::<Number>(0)?.try_into()?;
|
||||||
ctx.env.create_int64(fibonacci_native(n))
|
ctx.env.create_int64(fibonacci_native(n))
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@ fn init<'env>(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[js_function]
|
#[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))
|
Err(Error::new(Status::GenericFailure))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[js_function(1)]
|
#[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()?;
|
let n = ctx.get::<Number>(0)?.try_into()?;
|
||||||
ctx.env.create_int64(fibonacci_native(n))
|
ctx.env.create_int64(fibonacci_native(n))
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use napi_rs::{Result, Value, CallContext, Number};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
#[js_function(1)]
|
#[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()?;
|
let n = ctx.get::<Number>(0)?.try_into()?;
|
||||||
ctx.env.create_int64(fibonacci_native(n))
|
ctx.env.create_int64(fibonacci_native(n))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue