forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
std::error::Error: change the error iterator producer
To produce an error iterator `std::error::Chain` one had to call `<dyn Error>::chain()`, which was not very ergonomic, because you have to manually cast to a trait object, if you didn't already have one with the type erased. ``` let mut iter = (&my_error as &(dyn Error)).chain(); // or let mut iter = <dyn Error>::chain(&my_error); // or let mut iter = Error::chain(&my_error); ``` The `chain()` method can't be implemented on the Error trait, because of rust-lang#69161 `Chain::new()` replaces `<dyn Error>::chain()` as a good alternative without confusing users, why they can't use `my_error.chain()` directly. The `Error::sources()` method doesn't have this problem, so implement it more efficiently, than one could achieve this with `Chain::new().skip(1)`. Related: rust-lang#58520
- Loading branch information
Showing
1 changed file
with
67 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters