protocol CodableWithDefault: Codable {
static var `default`: Self { get }
}
extension Set: CodableWithDefault {
static var `default`: Set {
return Set()
}
}
这在 Swift 4 中运行良好,但从 4.1 开始它抱怨:
'CodableWithDefault' requires that 'Element' conform to 'Encodable'
我找不到任何方式来表达我想要的扩展Set
也受限于Element
实现Encodable
。
这在 Swift 4.1 中是否可行?