Files
swift-mirror/test/refactoring/AddCodableImplementation/Outputs/nested/codable.swift.expected
Louis D'hauwe 5d36507a2f [Refactoring] Add Codable refactoring action
Inserts the synthesized implementation.
As part of this, fix some ASTPrinter bugs.

rdar://87904700
2022-02-02 14:14:23 -08:00

30 lines
770 B
Plaintext

struct Response: Codable {
let pages: [Page]
struct Page: Codable {
let results: [Result]
struct Result: Codable {
let title: String
enum CodingKeys: CodingKey {
case title
}
init(from decoder: Decoder) throws {
let container: KeyedDecodingContainer<Response.Page.Result.CodingKeys> = try decoder.container(keyedBy: Response.Page.Result.CodingKeys.self)
self.title = try container.decode(String.self, forKey: Response.Page.Result.CodingKeys.title)
}
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: Response.Page.Result.CodingKeys.self)
try container.encode(self.title, forKey: Response.Page.Result.CodingKeys.title)
}
}
}
}