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:
parent
40291e2715
commit
9a19d477df
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user