Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary Copy constraint on durable::Storage::transaction() #710

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rozbb
Copy link

@rozbb rozbb commented Mar 4, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants