Skip to content

Commit 783b1de

Browse files
authored
[Foundation] Extracting the ReferenceConvertible conformance for CharacterSet (#5054)
1 parent e1b2a27 commit 783b1de

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

stdlib/public/SDK/Foundation/CharacterSet.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ internal final class _SwiftNSCharacterSet : _SwiftNativeNSCharacterSet, _SwiftNa
7474
*/
7575
public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgebra, _MutablePairBoxing {
7676
public typealias ReferenceType = NSCharacterSet
77-
77+
7878
internal typealias SwiftNSWrapping = _SwiftNSCharacterSet
7979
internal typealias ImmutableType = SwiftNSWrapping.ImmutableType
8080
internal typealias MutableType = SwiftNSWrapping.MutableType
@@ -134,19 +134,11 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
134134
return nil
135135
}
136136
}
137-
137+
138138
public var hashValue: Int {
139139
return _mapUnmanaged { $0.hashValue }
140140
}
141141

142-
public var description: String {
143-
return _mapUnmanaged { $0.description }
144-
}
145-
146-
public var debugDescription: String {
147-
return _mapUnmanaged { $0.debugDescription }
148-
}
149-
150142
private init(reference: NSCharacterSet) {
151143
_wrapped = _SwiftNSCharacterSet(immutableObject: reference)
152144
}
@@ -469,6 +461,16 @@ extension CharacterSet : _ObjectiveCBridgeable {
469461

470462
}
471463

464+
extension CharacterSet : CustomStringConvertible, CustomDebugStringConvertible {
465+
public var description: String {
466+
return _mapUnmanaged { $0.description }
467+
}
468+
469+
public var debugDescription: String {
470+
return _mapUnmanaged { $0.debugDescription }
471+
}
472+
}
473+
472474
extension NSCharacterSet : _HasCustomAnyHashableRepresentation {
473475
// Must be @nonobjc to avoid infinite recursion during bridging.
474476
@nonobjc

0 commit comments

Comments
 (0)