mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Inserts the synthesized implementation. As part of this, fix some ASTPrinter bugs. rdar://87904700
28 lines
630 B
Plaintext
28 lines
630 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?
|
|
|
|
enum CodingKeys: CodingKey {
|
|
case firstName
|
|
case lastName
|
|
}
|
|
|
|
func encode(to encoder: 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)
|
|
}
|
|
}
|