-
Notifications
You must be signed in to change notification settings - Fork 656
Description
SinkMapExt::sink_map_err
accepts an FnOnce
to map the error type at most once. A second error mapping will cause a panic because the mapping function has been consumed. As far as I can tell this dates back to futures-0.1 times when the Sink API documentation was quite explicit about possible panic conditions, e.g. "This method may panic in a few situations [...] - A previous call to start_send
or poll_complete
yielded an error." [1]
The current API documentation on the other hand is silent about panics, it only states that "In most cases, if the sink encounters an error, the sink will permanently be unable to receive items." [2] However using sink_map_err
on any Sink
type effectively prevents client code from calling any of its methods after an error has occurred if avoiding the panic from SinkMapErr
is the goal.
Now, my question is ― should the Sink API documentation be updated to better express the panic conditions as it used to be the case, or should SinkMapExt::sink_map_err
perhaps be changed to accept an FnMut
instead?