We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Result
1 parent 6155400 commit 390d011Copy full SHA for 390d011
Sources/ConcurrencyExtras/Result.swift
@@ -0,0 +1,14 @@
1
+extension Result where Failure == Swift.Error {
2
+ /// Creates a new result by evaluating an async throwing closure, capturing the returned value as
3
+ /// a success, or any thrown error as a failure.
4
+ ///
5
+ /// - Parameter body: A throwing closure to evaluate.
6
+ @_transparent
7
+ public init(catching body: () async throws -> Success) async {
8
+ do {
9
+ self = .success(try await body())
10
+ } catch {
11
+ self = .failure(error)
12
+ }
13
14
+}
0 commit comments