Skip to content

Commit c7fde6e

Browse files
rozbbMichael Rosenbergguybedford
authored
Removed Copy constraint on closure given to durable::Storage::transaction (#710)
Co-authored-by: Michael Rosenberg <[email protected]> Co-authored-by: Guy Bedford <[email protected]>
1 parent 3e586ed commit c7fde6e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

worker/src/durable.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,12 @@ impl Storage {
489489
fut.await.map(|_| ()).map_err(Error::from)
490490
}
491491

492-
pub async fn transaction<F, Fut>(&self, mut closure: F) -> Result<()>
492+
pub async fn transaction<F, Fut>(&self, closure: F) -> Result<()>
493493
where
494-
F: FnMut(Transaction) -> Fut + Copy + 'static,
494+
F: FnOnce(Transaction) -> Fut + 'static,
495495
Fut: Future<Output = Result<()>> + 'static,
496496
{
497-
let inner: Box<dyn FnMut(DurableObjectTransaction) -> js_sys::Promise> =
497+
let inner: Box<dyn FnOnce(DurableObjectTransaction) -> js_sys::Promise> =
498498
Box::new(move |t: DurableObjectTransaction| -> js_sys::Promise {
499499
future_to_promise(async move {
500500
closure(Transaction { inner: t })
@@ -503,7 +503,7 @@ impl Storage {
503503
.map(|_| JsValue::NULL)
504504
})
505505
});
506-
let clos = wasm_bindgen::closure::Closure::wrap(inner);
506+
let clos = wasm_bindgen::closure::Closure::once(inner);
507507
JsFuture::from(self.inner.transaction(&clos)?)
508508
.await
509509
.map_err(Error::from)

0 commit comments

Comments
 (0)