rust-block
rust-block copied to clipboard
Need to copy the block
It is important to copy your block to the heap (with the copy method) before passing it to Objective-C; this is because our ConcreteBlock is only meant to be copied once, and we can enforce this in Rust, but if Objective-C code were to copy it twice we could have a double free.
This is really unfortunate and error prone. It would be great to leverage the type system to do this automatically for us or at least enforce safety at compile time.
How about renaming the copy function and removing the Deref implementations to make the API more explicit?