(I assume that whatever implementation exists is similar for Rc'ed objects in Rust, assuming Swift is indeed parallel-memory-safe.)
(I assume that whatever implementation exists is similar for Rc'ed objects in Rust, assuming Swift is indeed parallel-memory-safe.)
I admit to not being intimately familiar with Swift, but I assume it is (or is aiming to be), because Objective-C objects are all atomically reference counted, and the language makes an effort to section off the unsafe parts (via names like "UnsafeMutablePointer").
> (I assume that whatever implementation exists is similar for Rc'ed objects in Rust, assuming Swift is indeed parallel-memory-safe.)
Rc is not thread safe, but the language and libraries prevent Rc'd objects from ever moving between threads, so the lack of thread safety of Rc doesn't make the language less thread-safe. There is a separate type, Arc, that is thread-safe and can be sent between threads. (Arc also prevents mutation of the protected data without a mutex or atomic operations.) Swift's approach, by contrast (as far as I know) is to atomically reference count all objects. (This approach is inherited from Objective-C, and more broadly Core Foundation. It mirrors COM and various other component systems.)