pub struct ClosureCtx { /* private fields */ }Expand description
Context for a Swift () -> T closure implemented in Rust.
Swift treats a closure context as a reference-counted heap object. A
non-escaping closure never touches the count, but an escaping one — a
Button’s action, say — is stored by the receiver, which retains it now and
releases it later. Handing Swift a plain Box means it eventually calls
swift_release on memory that is not a Swift object, and the process dies
with SIGBUS long after the call that caused it.
So the first two words mirror a Swift object header and carry the refcount pattern of a known immortal object, which makes retain and release no-ops.
Implementations§
Auto Trait Implementations§
impl !Send for ClosureCtx
impl !Sync for ClosureCtx
impl Freeze for ClosureCtx
impl RefUnwindSafe for ClosureCtx
impl Unpin for ClosureCtx
impl UnsafeUnpin for ClosureCtx
impl UnwindSafe for ClosureCtx
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more