Scala 2.13 中缺少导入 scala.collection.parallel

Missing import scala.collection.parallel in Scala 2.13

Parallel collections 在 Scala 2.12 中可以直接导入,就像这样

import scala.collection.parallel.immutable.ParVector
val pv = new ParVector[Int]

但是为什么在 Scala 2.13 中似乎缺少包 scala.collection.parallel

并行集合已在 Scala 2.13 中移动到单独的模块 scala/scala-parallel-collection

This Scala standard module contains the package scala.collection.parallel, with all of the parallel collections that used to be part of the Scala standard library.

For Scala 2.13, this module is a separate JAR that can be omitted from projects that do not use parallel collections.

因此从 2.13 开始我们需要以下依赖

libraryDependencies += "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.0"

并启用 .par 扩展方法导入

import scala.collection.parallel.CollectionConverters._

2.13 API docs but instead is published at javadoc.io/doc/org.scala-lang.modules/scala-parallel-collections_2.13 也不再提供相应的 scaladoc。