use extend::ext;
use wasm_bindgen::closure::Closure;
use wasm_bindgen::closure::IntoWasmClosure;
use wasm_bindgen::closure::WasmClosure;
#[ext]
pub impl<T1, T2> Closure<dyn FnMut(T1) -> T2> {
fn from_func<F>(func: F) -> Self
where
dyn FnMut(T1) -> T2: WasmClosure,
F: IntoWasmClosure<dyn FnMut(T1) -> T2> + 'static,
{
Closure::new(func)
}
}
#[ext]
pub impl<T2> Closure<dyn FnMut() -> T2> {
fn from_func_no_args<F>(func: F) -> Self
where
dyn FnMut() -> T2: WasmClosure,
F: IntoWasmClosure<dyn FnMut() -> T2> + 'static,
{
Closure::new(func)
}
}