@@ -407,26 +407,24 @@ extension Range: Hashable where Bound: Hashable {
407
407
408
408
extension Range : Codable where Bound: Codable {
409
409
private enum CodingKeys : String , CodingKey {
410
- case from
411
- case upTo
410
+ case lowerBound = " from "
411
+ case upperBound = " upTo "
412
412
}
413
413
414
- @inlinable
415
414
public init ( from decoder: Decoder ) throws {
416
415
let container = try decoder. container ( keyedBy: CodingKeys . self)
417
- let lowerBound = try container. decode ( Bound . self, forKey: . from )
418
- let upperBound = try container. decode ( Bound . self, forKey: . upTo )
416
+ let lowerBound = try container. decode ( Bound . self, forKey: . lowerBound )
417
+ let upperBound = try container. decode ( Bound . self, forKey: . upperBound )
419
418
guard lowerBound <= upperBound else {
420
- throw DecodingError . dataCorruptedError ( forKey: CodingKeys . upTo , in: container, debugDescription: " upperBound (upTo) cannot be lower than lowerBound (from) " )
419
+ throw DecodingError . dataCorruptedError ( forKey: CodingKeys . upperBound , in: container, debugDescription: " upperBound (upTo) cannot be lower than lowerBound (from) " )
421
420
}
422
421
self = lowerBound..< upperBound
423
422
}
424
423
425
- @inlinable
426
424
public func encode( to encoder: Encoder ) throws {
427
425
var container = encoder. container ( keyedBy: CodingKeys . self)
428
- try container. encode ( self . lowerBound, forKey: . from )
429
- try container. encode ( self . upperBound, forKey: . upTo )
426
+ try container. encode ( self . lowerBound, forKey: . lowerBound )
427
+ try container. encode ( self . upperBound, forKey: . upperBound )
430
428
}
431
429
}
432
430
@@ -474,19 +472,17 @@ extension PartialRangeUpTo: RangeExpression {
474
472
475
473
extension PartialRangeUpTo : Codable where Bound: Codable {
476
474
private enum CodingKeys : String , CodingKey {
477
- case beginningUpTo
475
+ case upperBound = " beginningUpTo "
478
476
}
479
477
480
- @inlinable
481
478
public init ( from decoder: Decoder ) throws {
482
479
let container = try decoder. container ( keyedBy: CodingKeys . self)
483
- self = ..< try container. decode ( Bound . self, forKey: . beginningUpTo )
480
+ self = try ( ..< container. decode ( Bound . self, forKey: . upperBound ) )
484
481
}
485
482
486
- @inlinable
487
483
public func encode( to encoder: Encoder ) throws {
488
484
var container = encoder. container ( keyedBy: CodingKeys . self)
489
- try container. encode ( self . upperBound, forKey: . beginningUpTo )
485
+ try container. encode ( self . upperBound, forKey: . upperBound )
490
486
}
491
487
}
492
488
@@ -533,19 +529,17 @@ extension PartialRangeThrough: RangeExpression {
533
529
534
530
extension PartialRangeThrough : Codable where Bound: Codable {
535
531
private enum CodingKeys : String , CodingKey {
536
- case beginningTo
532
+ case upperBound = " beginningTo "
537
533
}
538
534
539
- @inlinable
540
535
public init ( from decoder: Decoder ) throws {
541
536
let container = try decoder. container ( keyedBy: CodingKeys . self)
542
- self = ... try container. decode ( Bound . self, forKey: . beginningTo )
537
+ self = try ( ... container. decode ( Bound . self, forKey: . upperBound ) )
543
538
}
544
539
545
- @inlinable
546
540
public func encode( to encoder: Encoder ) throws {
547
541
var container = encoder. container ( keyedBy: CodingKeys . self)
548
- try container. encode ( self . upperBound, forKey: . beginningTo )
542
+ try container. encode ( self . upperBound, forKey: . upperBound )
549
543
}
550
544
}
551
545
@@ -687,19 +681,17 @@ extension PartialRangeFrom: Sequence
687
681
688
682
extension PartialRangeFrom : Codable where Bound: Codable {
689
683
private enum CodingKeys : String , CodingKey {
690
- case toEndFrom
684
+ case lowerBound = " toEndFrom "
691
685
}
692
686
693
- @inlinable
694
687
public init ( from decoder: Decoder ) throws {
695
688
let container = try decoder. container ( keyedBy: CodingKeys . self)
696
- self = try container. decode ( Bound . self, forKey: . toEndFrom ) ...
689
+ self = try container. decode ( Bound . self, forKey: . lowerBound ) ...
697
690
}
698
691
699
- @inlinable
700
692
public func encode( to encoder: Encoder ) throws {
701
693
var container = encoder. container ( keyedBy: CodingKeys . self)
702
- try container. encode ( self . lowerBound, forKey: . toEndFrom )
694
+ try container. encode ( self . lowerBound, forKey: . lowerBound )
703
695
}
704
696
}
705
697
0 commit comments