Skip to content

Instantly share code, notes, and snippets.

@robnadin
Created November 4, 2016 09:15
Show Gist options
  • Save robnadin/166c5655d9ab8c548c4d1c0862b068f4 to your computer and use it in GitHub Desktop.
Save robnadin/166c5655d9ab8c548c4d1c0862b068f4 to your computer and use it in GitHub Desktop.
// MARK: RawRepresentable Equality
func ==<T: Equatable, U: protocol<RawRepresentable, Equatable> where U.RawValue == T>(left: T?, right: U?) -> Bool {
return left == right?.rawValue
}
func !=<T: Equatable, U: protocol<RawRepresentable, Equatable> where U.RawValue == T>(left: T?, right: U?) -> Bool {
return left != right?.rawValue
}
func ==<T: Equatable, U: protocol<RawRepresentable, Equatable> where U.RawValue == T>(left: U?, right: T?) -> Bool {
return left?.rawValue == right
}
func !=<T: Equatable, U: protocol<RawRepresentable, Equatable> where U.RawValue == T>(left: U?, right: T?) -> Bool {
return left?.rawValue != right
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment