1

鉴于 UUID 类型是一个结构,我认为它会是Sendable. 但是编译器会生成一个警告:

struct S: Sendable {
    var int: Int
    var id: UUID // <-- Stored property 'id' of 'Sendable'-conforming struct 'S' has non-sendable type 'UUID'
}
4

1 回答 1

1

你可以这样做:


struct S: Sendable {
    var int: Int
    var id: UUID
}

extension UUID: UnsafeSendable { }

Xcode 告诉我使用@unchecked Sendable而不是,UnsafeSendable但它还不能识别@unchecked

于 2021-08-13T12:15:11.410 回答