Skip to content

Commit

Permalink
Make Document hashable
Browse files Browse the repository at this point in the history
  • Loading branch information
Joannis committed Mar 8, 2019
1 parent 9b66172 commit 20b8480
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/BSON/Document/Document+Equatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ extension Document: Equatable {
return lhs.makeData() == rhs.makeData()
}
}

extension Document: Hashable {
public func hash(into hasher: inout Hasher) {
self.makeByteBuffer().withUnsafeReadableBytes { buffer in
hasher.combine(bytes: buffer)
}
}
}

0 comments on commit 20b8480

Please sign in to comment.