@@ -16,7 +16,7 @@ public typealias uuid_string_t = (Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8
1616
1717/// Represents UUID strings, which can be used to uniquely identify types, interfaces, and other items.
1818@available ( macOS 10 . 8 , iOS 6 . 0 , tvOS 9 . 0 , watchOS 2 . 0 , * )
19- public struct UUID : Hashable , Equatable , CustomStringConvertible , Sendable , LosslessStringConvertible {
19+ public struct UUID : Hashable , Equatable , CustomStringConvertible , Sendable {
2020 public private( set) var uuid : uuid_t = ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
2121
2222 /* Create a new UUID with RFC 4122 version 4 random bytes */
@@ -58,12 +58,6 @@ public struct UUID : Hashable, Equatable, CustomStringConvertible, Sendable, Los
5858 self . uuid = uuid
5959 }
6060
61- /// Create a UUID from a string representation conforming to `LosslessStringConvertible`.
62- @available ( macOS 10 . 8 , iOS 6 . 0 , tvOS 9 . 0 , watchOS 2 . 0 , * )
63- public init ? ( _ description: String ) {
64- self . init ( uuidString: description)
65- }
66-
6761 /// Returns a string created from the UUID, such as "E621E1F8-C36C-495A-93FC-0C247A3E6E5F"
6862 public var uuidString : String {
6963 var bytes : uuid_string_t = ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
@@ -156,3 +150,11 @@ extension UUID : Comparable {
156150 return result < 0
157151 }
158152}
153+
154+ @available ( FoundationPreview 6 . 2 , * )
155+ extension UUID : LosslessStringConvertible {
156+ /// Create a UUID from a string representation conforming to `LosslessStringConvertible`.
157+ public init ? ( _ description: String ) {
158+ self . init ( uuidString: description)
159+ }
160+ }
0 commit comments