Swift Proposal: weak let
Currently, Swift classes with weak stored properties cannot be
Sendable, because weak properties have to be mutable, and mutable properties are not allowed inSendableclasses[…][…]
In fact, wrapping weak references in a single-property
structis a viable workaround to thevarrestriction in both properties and captures[…] The existence of this simple workaround is itself an argument that the prohibition ofweak letis not enforcing some fundamentally important rule.[…]
An explicit
weakcapture is now immutable under this proposal, like any other explicit capture. If the programmer really needs a mutable capture, they must capture a separateweak var.