Structs have the single-member layout equivalence rule, that is, if a struct has a single stored member (even if that member is a tuple or aggregate), that struct is layout equivalent with the single stored member. If there's an ABI boundary between you and the struct, then the struct has to be @frozen
for you to know if it is single-stored-member. Otherwise, no, IIRC.
If you have a struct with two Bool
fields in it, those might not be addressable as they could be packed into separate bits of the same byte. If you want an address, Swift has to materialize the address for you and perform a write-back when you're done. Improving how that is done is(/was) the role of accessors and safety is helped by exclusivity.
For the purposes of UP
family of types, IIUC, we're only talking about rules as they pertain to things that are already addressable and with already-defined layout. So, they would only apply to single-member structs, tuples, regions of memory, etc. You can store a tuple as the sole member of a struct to enforce or guarantee a certain layout and the addressability of individual tuple-members if you want to.