Quellcode durchsuchen

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

http://nshipster.com/equality/#hashing
Julien Chaumond vor 10 Jahren
Ursprung
Commit
6bfd68780a
1 geänderte Dateien mit 2 neuen und 2 gelöschten Zeilen
  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
 }