The RawOptionSetType example doesn't work at all, and it's been renamed to OptionSetType
timvermeulen opened this issue · 2 comments
timvermeulen commented
Something like this works:
struct Options: OptionSetType {
let rawValue: Int
init(rawValue: Int) {
self.rawValue = rawValue
}
init(number: Int) {
self.init(rawValue: 1 << number)
}
static let OptionOne = Options(number: 0)
static let OptionTwo = Options(number: 1)
static let OptionThree = Options(number: 2)
}
let options: Options = [.OptionOne, .OptionTwo]
options.contains(.OptionOne) // true
options.contains(.OptionThree) // false
iwasrobbed commented
@timvermeulen Sorry for the delay! Please feel free to open a pull request for any of these changes and I'd be happy to merge in
iwasrobbed commented
Will be fixed in a4f2664