=str - Significant simplification of the implementation of Source.unfoldInf
This commit is contained in:
parent
84fd5a9b2a
commit
22ccbcea39
1 changed files with 2 additions and 14 deletions
|
|
@ -289,20 +289,8 @@ object Source {
|
|||
* }
|
||||
* }}}
|
||||
*/
|
||||
def unfoldInf[S, E](s: S)(f: S ⇒ (S, E)): Source[E, Unit] = {
|
||||
Source.fromGraph(GraphDSL.create() { implicit b ⇒
|
||||
import GraphDSL.Implicits._
|
||||
|
||||
val uzip = b.add(UnzipWith(f))
|
||||
val cnct = b.add(Concat[S]())
|
||||
val init = Source.single(s)
|
||||
|
||||
init ~> cnct ~> uzip.in
|
||||
cnct <~ Flow[S].buffer(2, OverflowStrategy.backpressure) <~ uzip.out0
|
||||
|
||||
SourceShape(uzip.out1)
|
||||
}).withAttributes(DefaultAttributes.unfoldInf)
|
||||
}
|
||||
def unfoldInf[S, E](s: S)(f: S ⇒ (S, E)): Source[E, Unit] =
|
||||
unfold(s)(s ⇒ Some(f(s))).withAttributes(DefaultAttributes.unfoldInf)
|
||||
|
||||
/**
|
||||
* A `Source` with no elements, i.e. an empty stream that is completed immediately for every connected `Sink`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue