Very basic multicore question

FWIW this is available in swift-async-algorithms:


extension RangeReplaceableCollection {
  /// Creates a new instance of a collection containing the elements of an asynchronous sequence.
  ///
  /// - Parameter source: The asynchronous sequence of elements for the new collection.
  @inlinable
  public init<Source: AsyncSequence>(_ source: Source) async rethrows where Source.Element == Element {
    self.init()
    for try await item in source {
      append(item)
    }
  }
}
3 Likes