29 lines
537 B
Swift
29 lines
537 B
Swift
import Foundation
|
|
import Metal
|
|
|
|
extension Optional {
|
|
|
|
func unwrapped<T>(_ closure: (Wrapped) -> T) -> T? {
|
|
if case let .some(value) = self {
|
|
return closure(value)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
@discardableResult
|
|
func ifNil(_ closure: () -> Void) -> Self {
|
|
if self == nil {
|
|
closure()
|
|
}
|
|
return self
|
|
}
|
|
|
|
@discardableResult
|
|
func ifNotNil(_ closure: () -> Void) -> Self {
|
|
if self != nil {
|
|
closure()
|
|
}
|
|
return self
|
|
}
|
|
}
|