-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathSwift.swift
46 lines (40 loc) · 1.04 KB
/
Swift.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import Foundation
extension Character: CustomDumpRepresentable {
public var customDumpValue: Any {
String(self)
}
}
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
@available(macOS 13, iOS 16, watchOS 9, tvOS 16, *)
extension Duration: CustomDumpStringConvertible {
public var customDumpDescription: String {
self.formatted(
.units(
allowed: [.days, .hours, .minutes, .seconds, .milliseconds, .microseconds, .nanoseconds],
width: .wide
)
)
}
}
#endif
extension ObjectIdentifier: CustomDumpStringConvertible {
public var customDumpDescription: String {
self.debugDescription
.replacingOccurrences(of: "0x0*", with: "0x", options: .regularExpression)
}
}
extension StaticString: CustomDumpRepresentable {
public var customDumpValue: Any {
"\(self)"
}
}
extension UnicodeScalar: CustomDumpRepresentable {
public var customDumpValue: Any {
String(self)
}
}
extension AnyHashable: CustomDumpRepresentable {
public var customDumpValue: Any {
base
}
}