mirror of
https://github.com/apple/swift-nio
synced 2026-11-30 05:28:44 +00:00
Remove surplus Sendable requirements from FileSystem with methods (#2706)
Motivation: Many of the filesystem with methods have a requirement that the result type is sendable. In most cases this is not required as the result is not shared or sent. Modifications: Remove sendable requirement for result types where it is not required. Result: Users will not have to make so many types sendable.
This commit is contained in:
1 parent
359c461e55
commit
d3bdffd5e4
5 files changed
+14
-13
No files matched your search
@@ -31,9 +31,9 @@ public func withoutCancellation<R: Sendable>(
|
||||
/// Executes `fn` and then `tearDown`, which cannot be cancelled.
|
||||
@_spi(Testing)
|
||||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
public func withUncancellableTearDown<R: Sendable>(
|
||||
public func withUncancellableTearDown<R>(
|
||||
_ fn: () async throws -> R,
|
||||
tearDown: @escaping (Result<R, Error>) async throws -> Void
|
||||
tearDown: @escaping (Result<Void, Error>) async throws -> Void
|
||||
) async throws -> R {
|
||||
let result: Result<R, Error>
|
||||
do {
|
||||
@@ -42,9 +42,10 @@ public func withUncancellableTearDown<R: Sendable>(
|
||||
result = .failure(error)
|
||||
}
|
||||
|
||||
let errorOnlyResult: Result<Void, Error> = result.map { _ in return () }
|
||||
let tearDownResult: Result<Void, Error> = try await withoutCancellation {
|
||||
do {
|
||||
return .success(try await tearDown(result))
|
||||
return .success(try await tearDown(errorOnlyResult))
|
||||
} catch {
|
||||
return .failure(error)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user