@@ -1833,6 +1833,14 @@ public struct CodingUserInfoKey : RawRepresentable, Equatable, Hashable {
1833
1833
self . rawValue = rawValue
1834
1834
}
1835
1835
1836
+ /// Returns whether the given keys are equal.
1837
+ ///
1838
+ /// - parameter lhs: The key to compare against.
1839
+ /// - parameter rhs: The key to compare with.
1840
+ public static func == ( _ lhs: CodingUserInfoKey , _ rhs: CodingUserInfoKey ) -> Bool {
1841
+ return lhs. rawValue == rhs. rawValue
1842
+ }
1843
+
1836
1844
/// The key's hash value.
1837
1845
public var hashValue : Int {
1838
1846
return self . rawValue. hashValue
@@ -2441,7 +2449,14 @@ extension String : Codable {
2441
2449
}
2442
2450
}
2443
2451
2444
- public extension RawRepresentable where RawValue == Bool , Self : Codable {
2452
+ public extension RawRepresentable where RawValue == Bool , Self : Encodable {
2453
+ public func encode( to encoder: Encoder ) throws {
2454
+ var container = encoder. singleValueContainer ( )
2455
+ try container. encode ( self . rawValue)
2456
+ }
2457
+ }
2458
+
2459
+ public extension RawRepresentable where RawValue == Bool , Self : Decodable {
2445
2460
public init ( from decoder: Decoder ) throws {
2446
2461
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2447
2462
guard let value = Self ( rawValue: decoded) else {
@@ -2450,14 +2465,16 @@ public extension RawRepresentable where RawValue == Bool, Self : Codable {
2450
2465
2451
2466
self = value
2452
2467
}
2468
+ }
2453
2469
2470
+ public extension RawRepresentable where RawValue == Int , Self : Encodable {
2454
2471
public func encode( to encoder: Encoder ) throws {
2455
2472
var container = encoder. singleValueContainer ( )
2456
2473
try container. encode ( self . rawValue)
2457
2474
}
2458
2475
}
2459
2476
2460
- public extension RawRepresentable where RawValue == Int , Self : Codable {
2477
+ public extension RawRepresentable where RawValue == Int , Self : Decodable {
2461
2478
public init ( from decoder: Decoder ) throws {
2462
2479
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2463
2480
guard let value = Self ( rawValue: decoded) else {
@@ -2466,14 +2483,16 @@ public extension RawRepresentable where RawValue == Int, Self : Codable {
2466
2483
2467
2484
self = value
2468
2485
}
2486
+ }
2469
2487
2488
+ public extension RawRepresentable where RawValue == Int8 , Self : Encodable {
2470
2489
public func encode( to encoder: Encoder ) throws {
2471
2490
var container = encoder. singleValueContainer ( )
2472
2491
try container. encode ( self . rawValue)
2473
2492
}
2474
2493
}
2475
2494
2476
- public extension RawRepresentable where RawValue == Int8 , Self : Codable {
2495
+ public extension RawRepresentable where RawValue == Int8 , Self : Decodable {
2477
2496
public init ( from decoder: Decoder ) throws {
2478
2497
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2479
2498
guard let value = Self ( rawValue: decoded) else {
@@ -2482,14 +2501,16 @@ public extension RawRepresentable where RawValue == Int8, Self : Codable {
2482
2501
2483
2502
self = value
2484
2503
}
2504
+ }
2485
2505
2506
+ public extension RawRepresentable where RawValue == Int16 , Self : Encodable {
2486
2507
public func encode( to encoder: Encoder ) throws {
2487
2508
var container = encoder. singleValueContainer ( )
2488
2509
try container. encode ( self . rawValue)
2489
2510
}
2490
2511
}
2491
2512
2492
- public extension RawRepresentable where RawValue == Int16 , Self : Codable {
2513
+ public extension RawRepresentable where RawValue == Int16 , Self : Decodable {
2493
2514
public init ( from decoder: Decoder ) throws {
2494
2515
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2495
2516
guard let value = Self ( rawValue: decoded) else {
@@ -2498,14 +2519,16 @@ public extension RawRepresentable where RawValue == Int16, Self : Codable {
2498
2519
2499
2520
self = value
2500
2521
}
2522
+ }
2501
2523
2524
+ public extension RawRepresentable where RawValue == Int32 , Self : Encodable {
2502
2525
public func encode( to encoder: Encoder ) throws {
2503
2526
var container = encoder. singleValueContainer ( )
2504
2527
try container. encode ( self . rawValue)
2505
2528
}
2506
2529
}
2507
2530
2508
- public extension RawRepresentable where RawValue == Int32 , Self : Codable {
2531
+ public extension RawRepresentable where RawValue == Int32 , Self : Decodable {
2509
2532
public init ( from decoder: Decoder ) throws {
2510
2533
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2511
2534
guard let value = Self ( rawValue: decoded) else {
@@ -2514,14 +2537,16 @@ public extension RawRepresentable where RawValue == Int32, Self : Codable {
2514
2537
2515
2538
self = value
2516
2539
}
2540
+ }
2517
2541
2542
+ public extension RawRepresentable where RawValue == Int64 , Self : Encodable {
2518
2543
public func encode( to encoder: Encoder ) throws {
2519
2544
var container = encoder. singleValueContainer ( )
2520
2545
try container. encode ( self . rawValue)
2521
2546
}
2522
2547
}
2523
2548
2524
- public extension RawRepresentable where RawValue == Int64 , Self : Codable {
2549
+ public extension RawRepresentable where RawValue == Int64 , Self : Decodable {
2525
2550
public init ( from decoder: Decoder ) throws {
2526
2551
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2527
2552
guard let value = Self ( rawValue: decoded) else {
@@ -2530,14 +2555,16 @@ public extension RawRepresentable where RawValue == Int64, Self : Codable {
2530
2555
2531
2556
self = value
2532
2557
}
2558
+ }
2533
2559
2560
+ public extension RawRepresentable where RawValue == UInt , Self : Encodable {
2534
2561
public func encode( to encoder: Encoder ) throws {
2535
2562
var container = encoder. singleValueContainer ( )
2536
2563
try container. encode ( self . rawValue)
2537
2564
}
2538
2565
}
2539
2566
2540
- public extension RawRepresentable where RawValue == UInt , Self : Codable {
2567
+ public extension RawRepresentable where RawValue == UInt , Self : Decodable {
2541
2568
public init ( from decoder: Decoder ) throws {
2542
2569
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2543
2570
guard let value = Self ( rawValue: decoded) else {
@@ -2546,14 +2573,16 @@ public extension RawRepresentable where RawValue == UInt, Self : Codable {
2546
2573
2547
2574
self = value
2548
2575
}
2576
+ }
2549
2577
2578
+ public extension RawRepresentable where RawValue == UInt8 , Self : Encodable {
2550
2579
public func encode( to encoder: Encoder ) throws {
2551
2580
var container = encoder. singleValueContainer ( )
2552
2581
try container. encode ( self . rawValue)
2553
2582
}
2554
2583
}
2555
2584
2556
- public extension RawRepresentable where RawValue == UInt8 , Self : Codable {
2585
+ public extension RawRepresentable where RawValue == UInt8 , Self : Decodable {
2557
2586
public init ( from decoder: Decoder ) throws {
2558
2587
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2559
2588
guard let value = Self ( rawValue: decoded) else {
@@ -2562,14 +2591,16 @@ public extension RawRepresentable where RawValue == UInt8, Self : Codable {
2562
2591
2563
2592
self = value
2564
2593
}
2594
+ }
2565
2595
2596
+ public extension RawRepresentable where RawValue == UInt16 , Self : Encodable {
2566
2597
public func encode( to encoder: Encoder ) throws {
2567
2598
var container = encoder. singleValueContainer ( )
2568
2599
try container. encode ( self . rawValue)
2569
2600
}
2570
2601
}
2571
2602
2572
- public extension RawRepresentable where RawValue == UInt16 , Self : Codable {
2603
+ public extension RawRepresentable where RawValue == UInt16 , Self : Decodable {
2573
2604
public init ( from decoder: Decoder ) throws {
2574
2605
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2575
2606
guard let value = Self ( rawValue: decoded) else {
@@ -2578,14 +2609,16 @@ public extension RawRepresentable where RawValue == UInt16, Self : Codable {
2578
2609
2579
2610
self = value
2580
2611
}
2612
+ }
2581
2613
2614
+ public extension RawRepresentable where RawValue == UInt32 , Self : Encodable {
2582
2615
public func encode( to encoder: Encoder ) throws {
2583
2616
var container = encoder. singleValueContainer ( )
2584
2617
try container. encode ( self . rawValue)
2585
2618
}
2586
2619
}
2587
2620
2588
- public extension RawRepresentable where RawValue == UInt32 , Self : Codable {
2621
+ public extension RawRepresentable where RawValue == UInt32 , Self : Decodable {
2589
2622
public init ( from decoder: Decoder ) throws {
2590
2623
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2591
2624
guard let value = Self ( rawValue: decoded) else {
@@ -2594,14 +2627,16 @@ public extension RawRepresentable where RawValue == UInt32, Self : Codable {
2594
2627
2595
2628
self = value
2596
2629
}
2630
+ }
2597
2631
2632
+ public extension RawRepresentable where RawValue == UInt64 , Self : Encodable {
2598
2633
public func encode( to encoder: Encoder ) throws {
2599
2634
var container = encoder. singleValueContainer ( )
2600
2635
try container. encode ( self . rawValue)
2601
2636
}
2602
2637
}
2603
2638
2604
- public extension RawRepresentable where RawValue == UInt64 , Self : Codable {
2639
+ public extension RawRepresentable where RawValue == UInt64 , Self : Decodable {
2605
2640
public init ( from decoder: Decoder ) throws {
2606
2641
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2607
2642
guard let value = Self ( rawValue: decoded) else {
@@ -2610,14 +2645,16 @@ public extension RawRepresentable where RawValue == UInt64, Self : Codable {
2610
2645
2611
2646
self = value
2612
2647
}
2648
+ }
2613
2649
2650
+ public extension RawRepresentable where RawValue == Float , Self : Encodable {
2614
2651
public func encode( to encoder: Encoder ) throws {
2615
2652
var container = encoder. singleValueContainer ( )
2616
2653
try container. encode ( self . rawValue)
2617
2654
}
2618
2655
}
2619
2656
2620
- public extension RawRepresentable where RawValue == Float , Self : Codable {
2657
+ public extension RawRepresentable where RawValue == Float , Self : Decodable {
2621
2658
public init ( from decoder: Decoder ) throws {
2622
2659
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2623
2660
guard let value = Self ( rawValue: decoded) else {
@@ -2626,14 +2663,16 @@ public extension RawRepresentable where RawValue == Float, Self : Codable {
2626
2663
2627
2664
self = value
2628
2665
}
2666
+ }
2629
2667
2668
+ public extension RawRepresentable where RawValue == Double , Self : Encodable {
2630
2669
public func encode( to encoder: Encoder ) throws {
2631
2670
var container = encoder. singleValueContainer ( )
2632
2671
try container. encode ( self . rawValue)
2633
2672
}
2634
2673
}
2635
2674
2636
- public extension RawRepresentable where RawValue == Double , Self : Codable {
2675
+ public extension RawRepresentable where RawValue == Double , Self : Decodable {
2637
2676
public init ( from decoder: Decoder ) throws {
2638
2677
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2639
2678
guard let value = Self ( rawValue: decoded) else {
@@ -2642,14 +2681,16 @@ public extension RawRepresentable where RawValue == Double, Self : Codable {
2642
2681
2643
2682
self = value
2644
2683
}
2684
+ }
2645
2685
2686
+ public extension RawRepresentable where RawValue == String , Self : Encodable {
2646
2687
public func encode( to encoder: Encoder ) throws {
2647
2688
var container = encoder. singleValueContainer ( )
2648
2689
try container. encode ( self . rawValue)
2649
2690
}
2650
2691
}
2651
2692
2652
- public extension RawRepresentable where RawValue == String , Self : Codable {
2693
+ public extension RawRepresentable where RawValue == String , Self : Decodable {
2653
2694
public init ( from decoder: Decoder ) throws {
2654
2695
let decoded = try decoder. singleValueContainer ( ) . decode ( RawValue . self)
2655
2696
guard let value = Self ( rawValue: decoded) else {
@@ -2658,11 +2699,6 @@ public extension RawRepresentable where RawValue == String, Self : Codable {
2658
2699
2659
2700
self = value
2660
2701
}
2661
-
2662
- public func encode( to encoder: Encoder ) throws {
2663
- var container = encoder. singleValueContainer ( )
2664
- try container. encode ( self . rawValue)
2665
- }
2666
2702
}
2667
2703
2668
2704
//===----------------------------------------------------------------------===//
0 commit comments