You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create io::util::IteratorExtension to provide fail_on_error() and update io iterators to produce IoResults
Most IO related functions return an IoResult so that the caller can handle failure
in whatever way is appropriate. However, the `lines`, `bytes`, and `chars` iterators all
supress errors. This means that code that needs to handle errors can't use any of these
iterators. All three of these iterators were updated to produce IoResults.
The problem with returning IoResults is that the caller now *has* to handle error conditions
since the produced value is now wrapped in an IoResult. This complicates simple example
code or one-off programs. In order to mitigate that problem, a new extension trait,
io::util::IteratorExtension, is created that provides a new method for all iterators over
IoResults - fail_on_error(). This method wraps the iterator in a FailOnError iterator that
unwraps all results before producing them, but fails if a non-EndOfFile error is
encountered. This allows for simple programs to remain almost as simple as before.
With these changes, the existing behavior of supressing all errors for these iterators is
effectively no longer available.
Fixesrust-lang#12368
0 commit comments