2022-08-16 10:39:05 +02:00
|
|
|
import Foundation
|
|
|
|
import Metal
|
|
|
|
|
|
|
|
extension Optional {
|
|
|
|
|
2022-12-01 14:50:26 +01:00
|
|
|
func unwrapped<T>(_ closure: (Wrapped) -> T?) -> T? {
|
2022-08-16 10:39:05 +02:00
|
|
|
if case let .some(value) = self {
|
|
|
|
return closure(value)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2022-08-19 18:05:06 +02:00
|
|
|
|
|
|
|
@discardableResult
|
|
|
|
func ifNil(_ closure: () -> Void) -> Self {
|
|
|
|
if self == nil {
|
|
|
|
closure()
|
|
|
|
}
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
|
|
|
@discardableResult
|
|
|
|
func ifNotNil(_ closure: () -> Void) -> Self {
|
|
|
|
if self != nil {
|
|
|
|
closure()
|
|
|
|
}
|
|
|
|
return self
|
|
|
|
}
|
2022-08-16 10:39:05 +02:00
|
|
|
}
|