-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use internal iteration in the Sum and Product impls of Result and Option #62459
Use internal iteration in the Sum and Product impls of Result and Option #62459
Conversation
r? @shepmaster (rust_highfive has picked a reviewer for you, use r? to override) |
r? @scottmcm |
look, like we are in conflict #62883 I tried to keep Also, are you sure your code doesn't slow done thing ? Why should take a reference to an error should be better ? |
Ping @scottmcm — probably worth reviewing both related PRs. |
@Stargateur So it looks like my PR removes the duplication between |
@timvermeulen Sounds like a good plan. I approved #62883, and will wait on your update here. |
☔ The latest upstream changes (presumably #63057) made this pull request unmergeable. Please resolve the merge conflicts. |
@scottmcm I updated my branch, it should now match what I described in my previous comment 🙂 |
Hey! This is a ping from triage, we would like to know if you @scottmcm could give us a few more minutes to update us from last changes made by @timbertson . Thanks. |
Very nice! Great to see the @bors r+ |
📌 Commit 2e41ba8 has been approved by |
⌛ Testing commit 2e41ba8 with merge c0832e47f4cc1f8b75a2239104899a0d28b7280c... |
…eration, r=scottmcm Use internal iteration in the Sum and Product impls of Result and Option This PR adds internal iteration to the `ResultShunt` iterator type underlying the `Sum` and `Product` impls of `Result`. I had to change `ResultShunt` to hold a mutable reference to an error instead, similar to `itertools::ProcessResults`, in order to be able to pass the `ResultShunt` itself by value (which is necessary for internal iteration). `ResultShunt::process` can unfortunately no longer be an associated function because that would make it generic over the lifetime of the error reference, which wouldn't work, so I turned it into the free function `process_results`. I removed the `OptionShunt` type and forwarded the `Sum` and `Product` impls of `Option` to their respective impls of `Result` instead, to avoid having to repeat the internal iteration logic.
@bors retry rolled up. |
⌛ Testing commit 2e41ba8 with merge 320ac879e9127dea1139438ed82ca841b89c4954... |
…eration, r=scottmcm Use internal iteration in the Sum and Product impls of Result and Option This PR adds internal iteration to the `ResultShunt` iterator type underlying the `Sum` and `Product` impls of `Result`. I had to change `ResultShunt` to hold a mutable reference to an error instead, similar to `itertools::ProcessResults`, in order to be able to pass the `ResultShunt` itself by value (which is necessary for internal iteration). `ResultShunt::process` can unfortunately no longer be an associated function because that would make it generic over the lifetime of the error reference, which wouldn't work, so I turned it into the free function `process_results`. I removed the `OptionShunt` type and forwarded the `Sum` and `Product` impls of `Option` to their respective impls of `Result` instead, to avoid having to repeat the internal iteration logic.
@bors retry |
Rollup of 6 pull requests Successful merges: - #62459 (Use internal iteration in the Sum and Product impls of Result and Option) - #62821 (Not listed methods) - #62837 (Fix theme picker blur handler: always hide instead of switching) - #63286 (Replace error callback with Result) - #63296 (Deduplicate rustc_demangle in librustc_codegen_llvm) - #63298 (assume_init: warn about valid != safe) Failed merges: r? @ghost
☔ The latest upstream changes (presumably #63328) made this pull request unmergeable. Please resolve the merge conflicts. |
This PR adds internal iteration to the
ResultShunt
iterator type underlying theSum
andProduct
impls ofResult
. I had to changeResultShunt
to hold a mutable reference to an error instead, similar toitertools::ProcessResults
, in order to be able to pass theResultShunt
itself by value (which is necessary for internal iteration).ResultShunt::process
can unfortunately no longer be an associated function because that would make it generic over the lifetime of the error reference, which wouldn't work, so I turned it into the free functionprocess_results
.I removed the
OptionShunt
type and forwarded theSum
andProduct
impls ofOption
to their respective impls ofResult
instead, to avoid having to repeat the internal iteration logic.