mirror of
https://github.com/apple/swift-numerics
synced 2026-11-25 04:47:53 +00:00
Split Codable conformance of Complex into Encodable and Decodable. NFC.
Also make conformance to CustomDebugStringConvertible unconditional using String(reflecting:) on x and y.
This commit is contained in:
1 parent
d065a84750
commit
0ddfd0ead7
1 file changed
+4
-3
@@ -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)))"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user