diff --git a/test_module/src/lib.rs b/test_module/src/lib.rs index 949625cd..05b3384b 100644 --- a/test_module/src/lib.rs +++ b/test_module/src/lib.rs @@ -5,7 +5,7 @@ extern crate napi_rs_derive; extern crate futures; -use napi::{Any, Env, Error, Object, Result, Status, Value, CallContext}; +use napi::{Any, CallContext, Env, Error, Object, Result, Status, Value}; register_module!(test_module, init); @@ -13,21 +13,13 @@ fn init<'env>( env: &'env Env, exports: &'env mut Value<'env, Object>, ) -> Result>> { - exports.set_named_property( - "testSpawn", - env.create_function("testSpawn", test_spawn)?, - )?; - exports.set_named_property( - "testThrow", - env.create_function("testThrow", test_throw)?, - )?; + exports.set_named_property("testSpawn", env.create_function("testSpawn", test_spawn)?)?; + exports.set_named_property("testThrow", env.create_function("testThrow", test_throw)?)?; Ok(None) } #[js_function] -fn test_spawn<'a>( - ctx: CallContext<'a> -) -> Result> { +fn test_spawn<'a>(ctx: CallContext<'a>) -> Result> { use futures::executor::ThreadPool; use futures::StreamExt; let env = ctx.env; @@ -37,7 +29,7 @@ fn test_spawn<'a>( let (tx, rx) = futures::channel::mpsc::unbounded::(); let fut_values = async move { let fut_tx_result = async move { - (0..100).for_each(|v| { + (0..20).for_each(|v| { tx.unbounded_send(v).expect("Failed to send"); }) }; @@ -60,8 +52,6 @@ fn test_spawn<'a>( } #[js_function] -fn test_throw<'a>( - _ctx: CallContext<'a>, -) -> Result> { +fn test_throw<'a>(_ctx: CallContext<'a>) -> Result> { Err(Error::new(Status::GenericFailure)) }