From cab8f10169fc4ce5f0239514532a9be94517ec4f Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:41:44 -0500 Subject: [PATCH] Use generics instead of dynamic dispatch --- src/app.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/app.rs b/src/app.rs index 63abf62..4f2a475 100644 --- a/src/app.rs +++ b/src/app.rs @@ -74,15 +74,21 @@ impl eframe::App for BrowseApp { } #[cfg(target_arch = "wasm32")] -fn execute( - f: impl std::future::Future> + 'static, -) -> Option>> { +fn execute(f: F) -> Option>> +where + F: std::future::Future> + 'static, +{ Some(poll_promise::Promise::spawn_local(f)) } #[cfg(not(target_arch = "wasm32"))] -fn execute( - f: impl std::future::Future> + std::marker::Send + 'static, -) -> SaveLoadPromise { +fn execute(f: F) -> SaveLoadPromise +where + F: std::future::Future> + std::marker::Send + 'static, +{ Some(poll_promise::Promise::spawn_async(f)) } + +// fn execute + 'static>(f: F) { +// wasm_bindgen_futures::spawn_local(f); +// }