workers-rs
workers-rs copied to clipboard
Remove unnecessary Copy constraint on `durable::Storage::transaction()`
Currently, durable::Storage::transaction requires that its closure implement Copy. This is way too strong a requirement, since you can't even do things like:
let key: String = get_dur_obj_key();
storage.transaction(move |tx| async move {
let val = tx.get(&key).await?;
});
The compiler yells, saying the trait bound String: std::marker::Copy is not satisfied in {closure@...}.
Fortunately, there's no inherent reason why this closure needs to implement Copy. This PR changes the transaction semantics to make use of wasm_bindgen's built-in FnOnce support for futures.