mirror of
https://github.com/apple/swift-numerics
synced 2026-11-22 04:30:45 +00:00
And Real does not conform to CustomDebugStringConvertible, so can't access debugDescription property directly on x and y
25 lines
810 B
Swift
25 lines
810 B
Swift
//===--- Complex+StringConvertible.swift ----------------------*- swift -*-===//
|
|
//
|
|
// This source file is part of the Swift Numerics open source project
|
|
//
|
|
// Copyright (c) 2019-2025 Apple Inc. and the Swift Numerics project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
extension Complex: CustomStringConvertible {
|
|
public var description: String {
|
|
guard isFinite else { return "inf" }
|
|
return "(\(x), \(y))"
|
|
}
|
|
}
|
|
|
|
@_unavailableInEmbedded
|
|
extension Complex: CustomDebugStringConvertible {
|
|
public var debugDescription: String {
|
|
"Complex<\(RealType.self)>(\(String(reflecting: x)), \(String(reflecting: y)))"
|
|
}
|
|
}
|