fn main() {
let task = rfd::AsyncFileDialog::new().pick_file();
execute(async {
let file = task.await;
if let Some(file) = file {
#[cfg(not(target_arch = "wasm32"))]
println!("{:?}", file.path());
file.read().await;
}
});
loop {}
}
use std::future::Future;
#[cfg(not(target_arch = "wasm32"))]
fn execute<F: Future<Output = ()> + Send + 'static>(f: F) {
std::thread::spawn(move || futures::executor::block_on(f));
}
#[cfg(target_arch = "wasm32")]
fn execute<F: Future<Output = ()> + 'static>(f: F) {
wasm_bindgen_futures::spawn_local(f);
}