From fc0cdd9bba7612413a165e7c10ee00d614c98b82 Mon Sep 17 00:00:00 2001 From: Michael Rosenberg Date: Tue, 4 Mar 2025 13:30:29 -0500 Subject: [PATCH] Removed Copy constraint on closure given to durable::Storage::transaction --- worker/src/durable.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/worker/src/durable.rs b/worker/src/durable.rs index 7c1fd09a..5dbb5205 100644 --- a/worker/src/durable.rs +++ b/worker/src/durable.rs @@ -489,12 +489,12 @@ impl Storage { fut.await.map(|_| ()).map_err(Error::from) } - pub async fn transaction(&self, mut closure: F) -> Result<()> + pub async fn transaction(&self, closure: F) -> Result<()> where - F: FnMut(Transaction) -> Fut + Copy + 'static, + F: FnOnce(Transaction) -> Fut + 'static, Fut: Future> + 'static, { - let inner: Box js_sys::Promise> = + let inner: Box js_sys::Promise> = Box::new(move |t: DurableObjectTransaction| -> js_sys::Promise { future_to_promise(async move { closure(Transaction { inner: t }) @@ -503,7 +503,7 @@ impl Storage { .map(|_| JsValue::NULL) }) }); - let clos = wasm_bindgen::closure::Closure::wrap(inner); + let clos = wasm_bindgen::closure::Closure::once(inner); JsFuture::from(self.inner.transaction(&clos)?) .await .map_err(Error::from)