Seems you have read the Concurrency part of the Swift book, but it does not tell much about the current restrictions of async let.
Does swift 5.5 support this case???
If you mean using async let inside a code block of looping statement such as for-in, the answer is no.
In the accepted proposal SE-0317 async let bindings, you can find this description:
Specifically, async let declarations are not able to express dynamic numbers of tasks executing in parallel, like this group showcases:
func toyParallelMap<A, B>(_ items: [A], f: (A) async -> B) async -> [B] {
return await withTaskGroup(of: (Int, B).self) { group in
var bs = [B?](repeating: nil, count: items.count)
// spawn off processing all `f` mapping functions in parallel
// in reality, one might want to limit the "width" of these
for i in items.indices {
group.async { (i, await f(items[i])) }
}
// collect all results
for await (i, mapped) in group {
bs[i] = mapped
}
return bs.map { $0! }
}
}
In the above toyParallelMap the number of child-tasks is dynamic because it depends on the count of elements in the items array at runtime. Such patterns are not possible to express using async let because we'd have to know how many async let declarations to create at compile time.
I use TaskGroup already, but I want to know that swift supports it.
Seems you need to go on with TaskGroup in cases such as described in your opening post.