File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public typealias Codable = Encodable & Decodable
47
47
//===----------------------------------------------------------------------===//
48
48
49
49
/// A type that can be used as a key for encoding and decoding.
50
- public protocol CodingKey {
50
+ public protocol CodingKey : CustomStringConvertible , CustomDebugStringConvertible {
51
51
/// The string to use in a named collection (e.g. a string-keyed dictionary).
52
52
var stringValue : String { get }
53
53
@@ -67,6 +67,19 @@ public protocol CodingKey {
67
67
init ? ( intValue: Int )
68
68
}
69
69
70
+ extension CodingKey {
71
+ /// A textual representation of this key.
72
+ public var description : String {
73
+ let intValue = self . intValue? . description ?? " nil "
74
+ return " \( type ( of: self ) ) (stringValue: \" \( stringValue) \" , intValue: \( intValue) ) "
75
+ }
76
+
77
+ /// A textual representation of this key, suitable for debugging.
78
+ public var debugDescription : String {
79
+ return description
80
+ }
81
+ }
82
+
70
83
//===----------------------------------------------------------------------===//
71
84
// Encoder & Decoder
72
85
//===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments