13
13
package scala .collection .compat
14
14
15
15
import scala .collection .generic .CanBuildFrom
16
- import scala .collection .{ Iterable , mutable }
16
+ import scala .collection .mutable
17
17
18
18
/** Builds a collection of type `C` from elements of type `A` when a source collection of type `From` is available.
19
19
* Implicit instances of `BuildFrom` are available for all collection types.
@@ -23,16 +23,14 @@ import scala.collection.{Iterable, mutable}
23
23
* @tparam C Type of collection (e.g. `List[Int]`, `TreeMap[Int, String]`, etc.)
24
24
*/
25
25
trait BuildFrom [- From , - A , + C ] extends Any {
26
-
27
- def fromSpecificIterable (from : From )(it : Iterable [A ]): C
26
+ def fromSpecific (from : From )(it : IterableOnce [A ]): C
28
27
29
28
/** Get a Builder for the collection. For non-strict collection types this will use an intermediate buffer.
30
- * Building collections with `fromSpecificIterable ` is preferred because it can be lazy for lazy collections. */
29
+ * Building collections with `fromSpecific ` is preferred because it can be lazy for lazy collections. */
31
30
def newBuilder (from : From ): mutable.Builder [A , C ]
32
31
33
- @ deprecated(" Use newBuilder instead of apply()" , " 2.13.0" )
32
+ @ deprecated(" Use newBuilder() instead of apply()" , " 2.13.0" )
34
33
@ `inline` def apply (from : From ): mutable.Builder [A , C ] = newBuilder(from)
35
-
36
34
}
37
35
38
36
object BuildFrom {
@@ -41,7 +39,7 @@ object BuildFrom {
41
39
implicit def fromCanBuildFrom [From , A , C ](
42
40
implicit cbf : CanBuildFrom [From , A , C ]): BuildFrom [From , A , C ] =
43
41
new BuildFrom [From , A , C ] {
44
- def fromSpecificIterable (from : From )(it : Iterable [A ]): C = (cbf(from) ++= it).result()
42
+ def fromSpecific (from : From )(it : IterableOnce [A ]): C = (cbf(from) ++= it).result()
45
43
def newBuilder (from : From ): mutable.Builder [A , C ] = cbf(from)
46
44
}
47
45
0 commit comments