Skip to content

Commit e61a230

Browse files
committed
fix: use Closure::wrap instead of Closure::once for wasm-bindgen compatibility
Closure::once was added in wasm-bindgen 0.2.93, but many projects still use older versions. Changed to use Closure::wrap with FnMut which works across all wasm-bindgen versions. Fixes compilation error in River and other projects using older wasm-bindgen.
1 parent c12a6a9 commit e61a230

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "freenet-stdlib"
3-
version = "0.1.20"
3+
version = "0.1.21"
44
edition = "2021"
55
rust-version = "1.71.1"
66
publish = true

rust/src/client_api/browser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ impl WebApi {
8888
conn.set_onerror(Some(onerror_callback.as_ref().unchecked_ref()));
8989
onerror_callback.forget();
9090

91-
let onopen_callback = Closure::<dyn FnOnce()>::once(move || {
91+
let onopen_callback = Closure::wrap(Box::new(move || {
9292
onopen_handler();
93-
});
93+
}) as Box<dyn FnMut()>);
9494
// conn.add_event_listener_with_callback("open", onopen_callback.as_ref().unchecked_ref());
9595
conn.set_onopen(Some(onopen_callback.as_ref().unchecked_ref()));
9696
onopen_callback.forget();

0 commit comments

Comments
 (0)