Explorar o código

Socket: Make it clear that being equal is more than having equal hashes

http://nshipster.com/equality/#hashing
Julien Chaumond %!s(int64=10) %!d(string=hai) anos
pai
achega
6bfd68780a
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      Sources/Swifter/Socket.swift

+ 2 - 2
Sources/Swifter/Socket.swift

@@ -25,7 +25,7 @@ enum SocketError: ErrorType {
     case RecvFailed(String)
 }
 
-public class Socket : Hashable {
+public class Socket : Hashable, Equatable {
     
     public class func tcpSocketForListen(port: in_port_t = 8080, maxPendingConnection: Int32 = SOMAXCONN) throws -> Socket {
         
@@ -209,5 +209,5 @@ public class Socket : Hashable {
 
 
 public func ==(socket1: Socket, socket2: Socket) -> Bool {
-    return socket1.hashValue == socket2.hashValue
+    return socket1.socketFileDescriptor == socket2.socketFileDescriptor
 }