Skip to content

Commit 6352e87

Browse files
timers: use Closure::once for timeouts
1 parent 38130bf commit 6352e87

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

crates/timers/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,7 @@ pub mod callback {
122122
where
123123
F: 'static + FnOnce(),
124124
{
125-
// TODO: Use `FnOnce` here after this merges:
126-
// https://github.com/rustwasm/wasm-bindgen/pull/1281
127-
let mut callback = Some(callback);
128-
let closure = Closure::wrap(Box::new(move || {
129-
let callback = callback.take().unwrap_throw();
130-
callback();
131-
}) as Box<FnMut()>);
125+
let closure = Closure::once(callback);
132126

133127
let id = window()
134128
.set_timeout_with_callback_and_timeout_and_arguments_0(

0 commit comments

Comments
 (0)