diff --git a/src/quickjsrealmadapter.rs b/src/quickjsrealmadapter.rs index d405281bf7e..495b7317f13 100644 --- a/src/quickjsrealmadapter.rs +++ b/src/quickjsrealmadapter.rs @@ -26,7 +26,6 @@ use std::cell::RefCell; use std::collections::HashMap; use std::ffi::CString; use std::future::Future; -use std::i32; use std::os::raw::c_void; use std::rc::Rc; use std::sync::{Arc, Weak}; diff --git a/src/quickjsruntimeadapter.rs b/src/quickjsruntimeadapter.rs index 09b0313ce0e..92798c61ed1 100644 --- a/src/quickjsruntimeadapter.rs +++ b/src/quickjsruntimeadapter.rs @@ -213,30 +213,28 @@ unsafe extern "C" fn native_module_init( QuickJsRuntimeAdapter::do_with(|q_js_rt| { QuickJsRealmAdapter::with_context(ctx, |q_ctx| { - if let Some(res) = q_js_rt.with_all_module_loaders(|module_loader| { - if module_loader.has_module(q_ctx, module_name.as_str()) { - match module_loader.init_module(q_ctx, module) { - Ok(_) => { - Some(0) // ok - } - Err(e) => { - q_ctx.report_ex( - format!( - "Failed to init native module: {module_name} caused by {e}" - ) - .as_str(), - ); - Some(1) + q_js_rt + .with_all_module_loaders(|module_loader| { + if module_loader.has_module(q_ctx, module_name.as_str()) { + match module_loader.init_module(q_ctx, module) { + Ok(_) => { + Some(0) // ok + } + Err(e) => { + q_ctx.report_ex( + format!( + "Failed to init native module: {module_name} caused by {e}" + ) + .as_str(), + ); + Some(1) + } } + } else { + None } - } else { - None - } - }) { - res - } else { - 0 - } + }) + .unwrap_or(0) }) }) }