Skip to content

Commit 533e673

Browse files
authored
Merge pull request #48 from OddCoincidence/closure-once
timers: use Closure::once for timeouts
2 parents 38130bf + 6352e87 commit 533e673

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

crates/timers/src/lib.rs

+1-7
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)