Last active
August 29, 2018 17:08
-
-
Save nbw/5d4b2e73d76738afcbf3de4dd1b2a98e to your computer and use it in GitHub Desktop.
Hashable OpenSet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct OptionSetHash: OptionSet, Hashable { | |
let rawValue: Int | |
var hashValue: Int { | |
return self.rawValue | |
} | |
static let first = OptionSetHash(rawValue: 1 << 0) | |
static let second = OptionSetHash(rawValue: 1 << 1) | |
static let third = OptionSetHash(rawValue: 1 << 2) | |
// add more options here | |
} | |
func ==(lhs: OptionSetHash, rhs: OptionSetHash) -> Bool { | |
return lhs.hashValue == rhs.hashValue | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment