Skip to content

Commit f4e8cbb

Browse files
committed
Let CodingKey inherit CustomStringConvertible for better debugging
1 parent ff8787a commit f4e8cbb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

stdlib/public/core/Codable.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public typealias Codable = Encodable & Decodable
4747
//===----------------------------------------------------------------------===//
4848

4949
/// A type that can be used as a key for encoding and decoding.
50-
public protocol CodingKey {
50+
public protocol CodingKey: CustomStringConvertible {
5151
/// The string to use in a named collection (e.g. a string-keyed dictionary).
5252
var stringValue: String { get }
5353

@@ -67,6 +67,12 @@ public protocol CodingKey {
6767
init?(intValue: Int)
6868
}
6969

70+
extension CodingKey {
71+
public var description: String {
72+
return stringValue
73+
}
74+
}
75+
7076
//===----------------------------------------------------------------------===//
7177
// Encoder & Decoder
7278
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)