Skip to content

Commit cca8bfb

Browse files
committed
Renamed CodingKey raw names for better consistency
1 parent ac16b20 commit cca8bfb

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

stdlib/public/core/ClosedRange.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,19 @@ public typealias CountableClosedRange<Bound: Strideable> = ClosedRange<Bound>
492492
extension ClosedRange: Codable where Bound: Codable {
493493
private enum CodingKeys: String, CodingKey {
494494
case lowerBound = "from"
495-
case upperBound = "to"
495+
case upperBound = "through"
496496
}
497497

498498
public init(from decoder: Decoder) throws {
499499
let container = try decoder.container(keyedBy: CodingKeys.self)
500500
let lowerBound = try container.decode(Bound.self, forKey: .lowerBound)
501501
let upperBound = try container.decode(Bound.self, forKey: .upperBound)
502502
guard lowerBound <= upperBound else {
503-
throw DecodingError.dataCorruptedError(forKey: CodingKeys.upperBound, in: container, debugDescription: "upperBound (to) cannot be lower than lowerBound (from)")
503+
throw DecodingError.dataCorruptedError(
504+
forKey: CodingKeys.upperBound,
505+
in: container,
506+
debugDescription: "upperBound (to) cannot be less than lowerBound (through)"
507+
)
504508
}
505509
self = lowerBound...upperBound
506510
}

stdlib/public/core/Range.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,11 @@ extension Range: Codable where Bound: Codable {
416416
let lowerBound = try container.decode(Bound.self, forKey: .lowerBound)
417417
let upperBound = try container.decode(Bound.self, forKey: .upperBound)
418418
guard lowerBound <= upperBound else {
419-
throw DecodingError.dataCorruptedError(forKey: CodingKeys.upperBound, in: container, debugDescription: "upperBound (upTo) cannot be lower than lowerBound (from)")
419+
throw DecodingError.dataCorruptedError(
420+
forKey: CodingKeys.upperBound,
421+
in: container,
422+
debugDescription: "upperBound (upTo) cannot be less than lowerBound (from)"
423+
)
420424
}
421425
self = lowerBound..<upperBound
422426
}
@@ -472,7 +476,7 @@ extension PartialRangeUpTo: RangeExpression {
472476

473477
extension PartialRangeUpTo: Codable where Bound: Codable {
474478
private enum CodingKeys: String, CodingKey {
475-
case upperBound = "beginningUpTo"
479+
case upperBound = "fromStartUpTo"
476480
}
477481

478482
public init(from decoder: Decoder) throws {
@@ -529,7 +533,7 @@ extension PartialRangeThrough: RangeExpression {
529533

530534
extension PartialRangeThrough: Codable where Bound: Codable {
531535
private enum CodingKeys: String, CodingKey {
532-
case upperBound = "beginningTo"
536+
case upperBound = "fromStartThrough"
533537
}
534538

535539
public init(from decoder: Decoder) throws {

0 commit comments

Comments
 (0)