@@ -1080,8 +1080,9 @@ trait FlowOps[+Out, +Mat] {
10801080 * @param onComplete a function that transforms the ongoing state into an optional output element
10811081 */
10821082 def statefulMap [S , T ](create : () => S )(f : (S , Out ) => (S , T ), onComplete : S => Option [T ]): Repr [T ] =
1083- via(new StatefulMap [S , Out , T ](create, f, onComplete))
1084- .withAttributes(DefaultAttributes .statefulMap and SourceLocation .forLambda(f))
1083+ via(
1084+ new StatefulMap [S , Out , T ](create, f, onComplete)
1085+ .withAttributes(DefaultAttributes .statefulMap and SourceLocation .forLambda(f)))
10851086
10861087 /**
10871088 * Transform each stream element with the help of a resource.
@@ -1116,8 +1117,8 @@ trait FlowOps[+Out, +Mat] {
11161117 */
11171118 def mapWithResource [R , T ](create : () => R )(f : (R , Out ) => T , close : R => Option [T ]): Repr [T ] =
11181119 via(
1119- new StatefulMap [R , Out , T ](create, (resource, out) => (resource, f(resource, out)), resource => close(resource)))
1120- .withAttributes(DefaultAttributes .mapWithResource and SourceLocation .forLambda(f))
1120+ new StatefulMap [R , Out , T ](create, (resource, out) => (resource, f(resource, out)), resource => close(resource))
1121+ .withAttributes(DefaultAttributes .mapWithResource and SourceLocation .forLambda(f) ))
11211122
11221123 /**
11231124 * Transform each input element into an `Iterable` of output elements that is
@@ -2981,8 +2982,11 @@ trait FlowOps[+Out, +Mat] {
29812982 * '''Cancels when''' downstream cancels
29822983 */
29832984 def zipWithIndex : Repr [(Out , Long )] =
2984- statefulMap[Long , (Out , Long )](() => 0L )((index, out) => (index + 1L , (out, index)), _ => None )
2985- .withAttributes(DefaultAttributes .zipWithIndex)
2985+ via(
2986+ new StatefulMap [Long , Out , (Out , Long )](
2987+ () => 0L ,
2988+ (index, out) => (index + 1L , (out, index)),
2989+ ConstantFun .scalaAnyToNone).withAttributes(DefaultAttributes .zipWithIndex))
29862990
29872991 /**
29882992 * Interleave is a deterministic merge of the given [[Source ]] with elements of this [[Flow ]].
0 commit comments