=str Clean up Source#combine instance method code. (#31188)
This commit is contained in:
parent
042c25c9b2
commit
f6e73fa5ac
1 changed files with 1 additions and 14 deletions
|
|
@ -231,20 +231,7 @@ final class Source[+Out, +Mat](
|
|||
@deprecated("Use `Source.combine` on companion object instead", "2.5.5")
|
||||
def combine[T, U](first: Source[T, _], second: Source[T, _], rest: Source[T, _]*)(
|
||||
strategy: Int => Graph[UniformFanInShape[T, U], NotUsed]): Source[U, NotUsed] =
|
||||
Source.fromGraph(GraphDSL.create() { implicit b =>
|
||||
import GraphDSL.Implicits._
|
||||
val c = b.add(strategy(rest.size + 2))
|
||||
first ~> c.in(0)
|
||||
second ~> c.in(1)
|
||||
|
||||
@tailrec def combineRest(idx: Int, i: Iterator[Source[T, _]]): SourceShape[U] =
|
||||
if (i.hasNext) {
|
||||
i.next() ~> c.in(idx)
|
||||
combineRest(idx + 1, i)
|
||||
} else SourceShape(c.out)
|
||||
|
||||
combineRest(2, rest.iterator)
|
||||
})
|
||||
Source.combine(first, second, rest: _*)(strategy)
|
||||
|
||||
/**
|
||||
* Transform this source whose element is ``e`` into a source producing tuple ``(e, f(e))``
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue