1. 17
  1. 3

    Swift collection types are also value types, with copy-on-write to ensure performance as long as they aren’t shared.

    1. 2

      Rust’s Non-Copy types don’t have a direct equivalent in other languages like Swift or C++.

      They’re not quite like value types, because passing them by value doesn’t create a copy. The source is discarded/inaccessible to guarantee there’s logically only one copy, which eliminates need for copy-on-write or thread synchronization.

      But they aren’t reference types either, because despite this guarantee of a single instance, there’s no heap allocation or indirection involved, and they don’t have a stable address (for the struct itself. Vec’s backing store is still on the heap).

    2. 2

      There’s also this which has been optimized a lot: https://crates.io/crates/im