Skip to content

Instantly share code, notes, and snippets.

@nbw
Last active August 29, 2018 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbw/5d4b2e73d76738afcbf3de4dd1b2a98e to your computer and use it in GitHub Desktop.
Save nbw/5d4b2e73d76738afcbf3de4dd1b2a98e to your computer and use it in GitHub Desktop.
Hashable OpenSet
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