@@ -22,14 +22,14 @@ public struct UUID : ReferenceConvertible, Hashable, Equatable, CustomStringConv
2222
2323 /* Create a new UUID with RFC 4122 version 4 random bytes */
2424 public init ( ) {
25- withUnsafeMutablePointer ( & uuid) {
25+ withUnsafeMutablePointer ( to : & uuid) {
2626 uuid_generate_random ( unsafeBitCast ( $0, to: UnsafeMutablePointer< UInt8> . self ) )
2727 }
2828 }
2929
3030 fileprivate init ( reference: NSUUID ) {
3131 var bytes : uuid_t = ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
32- withUnsafeMutablePointer ( & bytes) {
32+ withUnsafeMutablePointer ( to : & bytes) {
3333 reference. getBytes ( unsafeBitCast ( $0, to: UnsafeMutablePointer< UInt8> . self ) )
3434 }
3535 uuid = bytes
@@ -39,7 +39,7 @@ public struct UUID : ReferenceConvertible, Hashable, Equatable, CustomStringConv
3939 ///
4040 /// Returns nil for invalid strings.
4141 public init ? ( uuidString string: String ) {
42- let res = withUnsafeMutablePointer ( & uuid) {
42+ let res = withUnsafeMutablePointer ( to : & uuid) {
4343 return uuid_parse ( string, unsafeBitCast ( $0, to: UnsafeMutablePointer< UInt8> . self ) )
4444 }
4545 if res != 0 {
@@ -56,15 +56,17 @@ public struct UUID : ReferenceConvertible, Hashable, Equatable, CustomStringConv
5656 public var uuidString : String {
5757 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 )
5858 var localValue = uuid
59- return withUnsafeMutablePointers ( & localValue, & bytes) { val, str -> String in
60- uuid_unparse ( unsafeBitCast ( val, to: UnsafePointer< UInt8> . self ) , unsafeBitCast ( str, to: UnsafeMutablePointer< Int8> . self ) )
61- return String ( cString: unsafeBitCast ( str, to: UnsafePointer< CChar> . self ) , encoding: . utf8) !
59+ return withUnsafeMutablePointer ( to: & localValue) { val in
60+ withUnsafeMutablePointer ( to: & bytes) { str in
61+ uuid_unparse ( unsafeBitCast ( val, to: UnsafePointer< UInt8> . self ) , unsafeBitCast ( str, to: UnsafeMutablePointer< Int8> . self ) )
62+ return String ( cString: unsafeBitCast ( str, to: UnsafePointer< CChar> . self ) , encoding: . utf8) !
63+ }
6264 }
6365 }
6466
6567 public var hashValue : Int {
6668 var localValue = uuid
67- return withUnsafeMutablePointer ( & localValue) {
69+ return withUnsafeMutablePointer ( to : & localValue) {
6870 return Int ( bitPattern: CFHashBytes ( unsafeBitCast ( $0, to: UnsafeMutablePointer< UInt8> . self ) , CFIndex ( sizeof ( uuid_t. self) ) ) )
6971 }
7072 }
@@ -81,7 +83,7 @@ public struct UUID : ReferenceConvertible, Hashable, Equatable, CustomStringConv
8183
8284 fileprivate var reference : NSUUID {
8385 var bytes = uuid
84- return withUnsafePointer ( & bytes) {
86+ return withUnsafePointer ( to : & bytes) {
8587 return NSUUID ( uuidBytes: unsafeBitCast ( $0, to: UnsafePointer< UInt8> . self ) )
8688 }
8789 }
0 commit comments