From 0ddfd0ead7c38452685322ad4bf705fe5e0dfd12 Mon Sep 17 00:00:00 2001 From: Stephen Canon Date: Sun, 10 Nov 2019 14:32:09 -0500 Subject: [PATCH] Split Codable conformance of Complex into Encodable and Decodable. NFC. Also make conformance to CustomDebugStringConvertible unconditional using String(reflecting:) on x and y. --- Sources/Complex/Complex.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/Complex/Complex.swift b/Sources/Complex/Complex.swift index 5f45167..12fec44 100644 --- a/Sources/Complex/Complex.swift +++ b/Sources/Complex/Complex.swift @@ -347,7 +347,8 @@ extension Complex: Hashable { // The synthesized conformance works correction for this protocol, unlike // Hashable and Equatable; all we need to do is specify that we conform. // FloatingPoint does not refine Codable, so this is a conditional conformance. -extension Complex: Codable where RealType: Codable { } +extension Complex: Encodable where RealType: Encodable { } +extension Complex: Decodable where RealType: Decodable { } // MARK: - Formatting extension Complex: CustomStringConvertible { @@ -359,9 +360,9 @@ extension Complex: CustomStringConvertible { } } -extension Complex: CustomDebugStringConvertible where RealType: CustomDebugStringConvertible { +extension Complex: CustomDebugStringConvertible { public var debugDescription: String { - "Complex<\(RealType.self)>(\(x.debugDescription), \(y.debugDescription))" + "Complex<\(RealType.self)>(\(String(reflecting: x)), \(String(reflecting: y)))" } }