this lives in Main.main
:
try await s3.connect
{
for asset:StaticAsset in StaticAsset.allCases
{
let content:[UInt8] = try assets.appending(asset.source).read()
let path:String = asset.path(prepending: version)
print("Uploading \(path)...")
try await $0.put(content,
using: .standard,
path: path,
type: asset.type)
}
}
the strict concurrency mode doesn’t like this too much.
passing argument of non-sendable type
'(AWS.S3Client.Connection) async throws -> ()' outside of
main actor-isolated context may introduce data races
Main.swift(43, 9): a function type must be marked '@Sendable'
to conform to 'Sendable'
the fix is straightforward enough:
{
@Sendable (connection:AWS.S3Client.Connection) in
...
but this means we effectively can’t use the $0
shorthand syntax with async
closures that take non-Sendable
arguments.
why can’t the compiler just infer the missing @Sendable
attribute?