-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 fold
in Iterator::last
default implementation
#62481
Use fold
in Iterator::last
default implementation
#62481
Conversation
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
So |
aa0c942
to
23450c3
Compare
Regarding The |
Mmh. I didn't think about that. I'll change the title. |
for_each
in Iterator::last
default implementation
Looks good; thanks for the PR! @bors r+ rollup |
📌 Commit 23450c3da83366c67bda42efb827509bba581df5 has been approved by |
It shouldn't matter, but you may as well use |
I just did a quick benchmark and |
I'm surprised it is that much faster wow! Could you share your benchmark code / data? |
Oops, I forgot running the benchmark with |
I do think |
for_each
in Iterator::last
default implementationfold
in Iterator::last
default implementation
Replace last impl with fold
30e6ec3
to
76a8bc2
Compare
@scottmcm squashed it up |
📌 Commit 76a8bc2 has been approved by |
…each, r=scottmcm Use `fold` in `Iterator::last` default implementation We already use it in all the other methods. Consistency + potential perf is a pretty nice win!
Rollup of 5 pull requests Successful merges: - #62275 (rustc_mir: treat DropAndReplace as Drop + Assign in qualify_consts.) - #62465 (Sometimes generate storage statements for temporaries with type `!`) - #62481 (Use `fold` in `Iterator::last` default implementation) - #62493 (#62357: doc(ptr): add example for {read,write}_unaligned) - #62532 (Some more cleanups to syntax::print) Failed merges: r? @ghost
Rollup of 5 pull requests Successful merges: - #62275 (rustc_mir: treat DropAndReplace as Drop + Assign in qualify_consts.) - #62465 (Sometimes generate storage statements for temporaries with type `!`) - #62481 (Use `fold` in `Iterator::last` default implementation) - #62493 (#62357: doc(ptr): add example for {read,write}_unaligned) - #62532 (Some more cleanups to syntax::print) Failed merges: r? @ghost
We already use it in all the other methods. Consistency + potential perf is a pretty nice win!