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 inSendable
classes[…][…]
In fact, wrapping weak references in a single-property
struct
is a viable workaround to thevar
restriction in both properties and captures[…] The existence of this simple workaround is itself an argument that the prohibition ofweak let
is not enforcing some fundamentally important rule.[…]
An explicit
weak
capture 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
.