diff --git a/rust_crate/src/interface.rs b/rust_crate/src/interface.rs index 0b1d8fcb..880cf91e 100644 --- a/rust_crate/src/interface.rs +++ b/rust_crate/src/interface.rs @@ -28,7 +28,7 @@ pub struct DartSignal { #[cfg(not(target_family = "wasm"))] pub fn start_rust_logic(main_future: F) -> Result<()> where - F: Future + Send + 'static, + F: Future + Send + 'static, { start_rust_logic_real(main_future) } @@ -39,7 +39,7 @@ where #[cfg(target_family = "wasm")] pub fn start_rust_logic(main_future: F) -> Result<()> 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 3494c314..ea81574b 100644 --- a/rust_crate/src/interface_os.rs +++ b/rust_crate/src/interface_os.rs @@ -36,7 +36,7 @@ static SHUTDOWN_SENDER: ShutdownSenderLock = OnceLock::new(); pub fn start_rust_logic_real(main_future: F) -> Result<()> where - F: Future + Send + 'static, + F: Future + Send + 'static, { // Enable backtrace output for panics. #[cfg(debug_assertions)] @@ -68,9 +68,7 @@ where { let tokio_runtime = Builder::new_current_thread().enable_all().build()?; thread::spawn(move || { - tokio_runtime.spawn(async { - main_future.await; - }); + tokio_runtime.spawn(main_future); tokio_runtime.block_on(shutdown_receiver); // Dropping the tokio runtime makes it shut down. drop(tokio_runtime); diff --git a/rust_crate/src/interface_web.rs b/rust_crate/src/interface_web.rs index e8cc4330..9bb6e0f9 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<()> where - F: Future + 'static, + F: Future + 'static, { // Add kind description for panics. #[cfg(debug_assertions)] @@ -17,9 +17,7 @@ where } // Run the main function. - spawn_local(async { - main_future.await; - }); + spawn_local(main_future); Ok(()) }