* 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
|
|
@ -36,6 +36,11 @@ object Sink {
|
|||
* The returned [[java.util.concurrent.CompletionStage]] 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 reduce[In](f: function.Function2[In, In, In]): Sink[In, CompletionStage[In]] =
|
||||
new Sink(scaladsl.Sink.reduce[In](f.apply).toCompletionStage())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue