mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
13 lines
353 B
Swift
13 lines
353 B
Swift
// RUN: %target-swift-frontend -emit-ir %s
|
|
|
|
@discardableResult public func applyWrapped<T, U>(function: Optional<(T) -> U>, to value: Optional<T>) -> Optional<U> {
|
|
switch (function, value) {
|
|
case (let .some(f), let .some(v)):
|
|
return .some(f(v))
|
|
case (.none, _):
|
|
return .none
|
|
case (_, .none):
|
|
return .none
|
|
}
|
|
}
|