16 lines
349 B
Swift
16 lines
349 B
Swift
//
|
|
// Copyright 2023 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension Result where Failure == Error {
|
|
public init(catching block: () async throws -> Success) async {
|
|
do {
|
|
self = .success(try await block())
|
|
} catch {
|
|
self = .failure(error)
|
|
}
|
|
}
|
|
}
|