=str - Significant simplification of the implementation of Source.unfoldInf

This commit is contained in:
Viktor Klang 2016-01-03 23:08:26 +01:00
parent 84fd5a9b2a
commit 22ccbcea39

View file

@ -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`.