web-async 0.1.5

Async helpers and utilities for WASM
Documentation
use std::future::Future;

use crate::MaybeSend;

// It's not pretty, but we have per-platform implementations of spawn.
// The main problem is Send; it's an annoying trait that colors everything.
// The rest of this crate is Send agnostic so it will work on WASM.
// TODO: use a send feature and make this runtime agnostic?

#[track_caller]
pub fn spawn<F: Future<Output = ()> + MaybeSend + 'static>(f: F) {
	#[cfg(feature = "tracing")]
	let f = tracing::Instrument::in_current_span(f);

	#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
	tokio::task::spawn(f);

	#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
	wasm_bindgen_futures::spawn_local(f);
}