mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* Support extensions including conditional conformance * Correct access modifiers * More correct lookup for the synthesized declarations * Avoid printing decls in nested types (rdar://98025945)
28 lines
642 B
Plaintext
28 lines
642 B
Plaintext
|
|
struct User: Codable {
|
|
let firstName: String
|
|
let lastName: String?
|
|
}
|
|
|
|
struct User_D: Decodable {
|
|
let firstName: String
|
|
let lastName: String?
|
|
}
|
|
|
|
struct User_E: Encodable {
|
|
let firstName: String
|
|
let lastName: String?
|
|
|
|
private enum CodingKeys: CodingKey {
|
|
case firstName
|
|
case lastName
|
|
}
|
|
|
|
func encode(to encoder: any Encoder) throws {
|
|
var container: KeyedEncodingContainer<User_E.CodingKeys> = encoder.container(keyedBy: User_E.CodingKeys.self)
|
|
|
|
try container.encode(self.firstName, forKey: User_E.CodingKeys.firstName)
|
|
try container.encodeIfPresent(self.lastName, forKey: User_E.CodingKeys.lastName)
|
|
}
|
|
}
|