소스 검색

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

http://nshipster.com/equality/#hashing
Julien Chaumond 10 년 전
부모
커밋
6bfd68780a
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  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
 }