Created
July 18, 2016 07:05
-
-
Save oozoofrog/1825aa36dcb4d27988afeb76937f4ed5 to your computer and use it in GitHub Desktop.
Custom operator for OptionSetType ref: http://qiita.com/DevLife1978/items/c66abd557e8b465728d3
This file contains 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
func -=<O: OptionSetType where O.RawValue == UInt32>(inout lhs: O, rhs: O) { | |
lhs = O(rawValue: lhs.rawValue ^ rhs.rawValue) | |
} | |
func +=<O: OptionSetType where O.RawValue == UInt32>(inout lhs: O, rhs: O) { | |
lhs = O(rawValue: lhs.rawValue | rhs.rawValue) | |
} | |
func +<O: OptionSetType where O.RawValue == UInt32>(lhs: O, rhs: O) -> O { | |
return O(rawValue: lhs.rawValue | rhs.rawValue) | |
} | |
func -<O: OptionSetType where O.RawValue == UInt32>(lhs: O, rhs: O) -> O { | |
return O(rawValue: lhs.rawValue ^ rhs.rawValue) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment