* str #20262 reduce should fail explicitly on empty stream * str #20262 document reduce behaviour on empty stream
This commit is contained in:
parent
503a77f515
commit
b9ab232cac
8 changed files with 67 additions and 14 deletions
|
|
@ -107,6 +107,11 @@ final class Source[+Out, +Mat](private[stream] override val module: Module)
|
|||
* The returned [[scala.concurrent.Future]] will be completed with value of the final
|
||||
* function evaluation when the input stream ends, or completed with `Failure`
|
||||
* if there is a failure signaled in the stream.
|
||||
*
|
||||
* If the stream is empty (i.e. completes before signalling any elements),
|
||||
* the reduce stage will fail its downstream with a [[NoSuchElementException]],
|
||||
* which is semantically in-line with that Scala's standard library collections
|
||||
* do in such situations.
|
||||
*/
|
||||
def runReduce[U >: Out](f: (U, U) ⇒ U)(implicit materializer: Materializer): Future[U] =
|
||||
runWith(Sink.reduce(f))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue