diff --git a/rust_crate/src/interface.rs b/rust_crate/src/interface.rs index 0578de13..05b78f00 100644 --- a/rust_crate/src/interface.rs +++ b/rust_crate/src/interface.rs @@ -27,9 +27,10 @@ pub struct DartSignal { /// the `Runtime` object itself might be moved between threads, /// along with all the tasks it manages. #[cfg(not(target_family = "wasm"))] -pub fn start_rust_logic(main_future: F) -> Result<(), RinfError> +pub fn start_rust_logic(main_future: F) -> Result<(), RinfError> where - F: Future + Send + 'static, + F: Future + Send + 'static, + T: Send + 'static, { start_rust_logic_real(main_future) } @@ -40,7 +41,7 @@ where #[cfg(target_family = "wasm")] pub fn start_rust_logic(main_future: F) -> Result<(), RinfError> where - F: Future + 'static, + F: Future + 'static, { start_rust_logic_real(main_future) } diff --git a/rust_crate/src/interface_os.rs b/rust_crate/src/interface_os.rs index 7d72a025..9c17373e 100644 --- a/rust_crate/src/interface_os.rs +++ b/rust_crate/src/interface_os.rs @@ -37,9 +37,10 @@ pub extern "C" fn prepare_isolate_extern(port: i64) { type ShutdownSenderLock = OnceLock>>>; static SHUTDOWN_SENDER: ShutdownSenderLock = OnceLock::new(); -pub fn start_rust_logic_real(main_future: F) -> Result<(), RinfError> +pub fn start_rust_logic_real(main_future: F) -> Result<(), RinfError> where - F: Future + Send + 'static, + F: Future + Send + 'static, + T: Send + 'static, { // Enable backtrace output for panics. #[cfg(debug_assertions)] diff --git a/rust_crate/src/interface_web.rs b/rust_crate/src/interface_web.rs index a32b0c4b..241e37a3 100644 --- a/rust_crate/src/interface_web.rs +++ b/rust_crate/src/interface_web.rs @@ -6,7 +6,7 @@ use wasm_bindgen_futures::spawn_local; pub fn start_rust_logic_real(main_future: F) -> Result<(), RinfError> where - F: Future + 'static, + F: Future + 'static, { // Add kind description for panics. #[cfg(debug_assertions)] @@ -17,7 +17,9 @@ where } // Run the main function. - spawn_local(main_future); + spawn_local(async { + main_future.await; + }); Ok(()) }