1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 12:23:08 +03:00

Parameterized Optional equality.

This commit is contained in:
Rob Rix 2015-10-02 16:48:44 -04:00
parent 40291e2715
commit 9a19d477df

View File

@ -12,3 +12,16 @@ func >>> <T, U, V> (f: T -> U, g: U -> V) -> T -> V {
return { g(f($0)) }
}
extension Optional {
static func equals(param: (Wrapped, Wrapped) -> Bool)(_ left: Wrapped?, _ right: Wrapped?) -> Bool {
switch (left, right) {
case let (.Some(a), .Some(b)):
return param(a, b)
case (.None, .None):
return true
default:
return false
}
}
}