doc: fix example

This commit is contained in:
LongYinan 2020-04-27 10:35:48 +08:00
parent 26f80b1511
commit 86c166eece
No known key found for this signature in database
GPG key ID: A3FFE134A3E20881
2 changed files with 2 additions and 2 deletions

View file

@ -23,7 +23,7 @@ fn test_throw<'a>(_ctx: CallContext) -> Result<Value<'a, Any>> {
Err(Error::new(Status::GenericFailure)) Err(Error::new(Status::GenericFailure))
} }
#[js_function] #[js_function(1)]
fn fibonacci<'env>(ctx: CallContext<'env>) -> Result<Value<'env, Number>> { fn fibonacci<'env>(ctx: CallContext<'env>) -> Result<Value<'env, 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))

View file

@ -9,7 +9,7 @@ extern crate napi_rs_derive;
use napi_rs::{Result, Value, CallContext, Number}; use napi_rs::{Result, Value, CallContext, Number};
use std::convert::TryInto; use std::convert::TryInto;
#[js_function] #[js_function(1)]
fn fibonacci<'env>(ctx: CallContext<'env>) -> Result<Value<'env, Number>> { fn fibonacci<'env>(ctx: CallContext<'env>) -> Result<Value<'env, 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))