-
Notifications
You must be signed in to change notification settings - Fork 63
Description
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
?