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

Allow FnMut in blocks? #571

Open
madsmtm opened this issue Feb 2, 2024 · 0 comments
Open

Allow FnMut in blocks? #571

madsmtm opened this issue Feb 2, 2024 · 0 comments
Labels
A-block2 Affects the `block2` crate enhancement New feature or request

Comments

@madsmtm
Copy link
Owner

madsmtm commented Feb 2, 2024

Upstream issue: SSheldon/rust-block#12.

Should we allow Block<dyn FnMut()>, and how would we do it safely?

At the very least, we'd have to prevent any form of Block::copy/RcBlock::clone on these, as that could lead to multiple mutable references being present. In particular, it is difficult to prevent re-entrancy if the block is shared.

This decision is blocked on a resolution in #563, though we might still decide to allow FnMut in block2, even if we don't allow it in objc2, as most (non-@escaping, non-@Sendable, see #572) blocks (probably) really are safely mutable.

See also #168 (comment) for discussion on why FnOnce is impossible, we should document that somewhere more visible when tackling this issue. Or maybe add RcBlock::once, similar to wasm-bindgen?

@madsmtm madsmtm added enhancement New feature or request A-block2 Affects the `block2` crate labels Feb 2, 2024
@madsmtm madsmtm mentioned this issue Feb 2, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-block2 Affects the `block2` crate enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant