Skip to content

Replace some once(x).chain(once(y)) with [x, y] IntoIter - #77514

Merged
bors merged 1 commit into
rust-lang:masterfrom
scottmcm:less-once-chain-once
Oct 5, 2020
Merged

Replace some once(x).chain(once(y)) with [x, y] IntoIter#77514
bors merged 1 commit into
rust-lang:masterfrom
scottmcm:less-once-chain-once

Conversation

@scottmcm

@scottmcmscottmcm commented Oct 3, 2020

Copy link
Copy Markdown
Member

Now that we have by-value array iterators that are already used...

For example,

- once(self.type_ns).chain(once(self.value_ns)).chain(once(self.macro_ns)).filter_map(|it| it)+ IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it)

Now that we have by-value array iterators...
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 3, 2020
@jyn514jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 4, 2020
@jyn514

Copy link
Copy Markdown
Member

Is there an A-dogfooding label? 😆

@estebank

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Oct 4, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit d74b8e0 has been approved by estebank

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 4, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 5, 2020
Rollup of 11 pull requests
Successful merges:
- rust-lang#75853 (Use more intra-doc-links in `core::fmt`)
- rust-lang#75928 (Remove trait_selection error message in specific case)
- rust-lang#76329 (Add check for doc alias attribute at crate level)
- rust-lang#77219 (core::global_allocator docs link to std::alloc::GlobalAlloc)
- rust-lang#77395 (BTreeMap: admit the existence of leaf edges in comments)
- rust-lang#77407 (Improve build-manifest to work with the improved promote-release)
- rust-lang#77426 (Include scope id in SocketAddrV6::Display)
- rust-lang#77439 (Fix missing diagnostic span for `impl Trait` with const generics, and add various tests for `min_const_generics` and `const_generics`)
- rust-lang#77471 (BTreeMap: refactoring around edges, missed spots)
- rust-lang#77512 (Allow `Abort` terminators in all const-contexts)
- rust-lang#77514 (Replace some once(x).chain(once(y)) with [x, y] IntoIter)
Failed merges:
r? `@ghost`
@bors
bors merged commit 9dbc9ed into rust-lang:masterOct 5, 2020
@rustbotrustbot added this to the 1.49.0 milestone Oct 5, 2020
use std::iter::once;

once(self.type_ns).chain(once(self.value_ns)).chain(once(self.macro_ns)).filter_map(|it| it)
IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could have been .flatten()?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frustratingly, flatten gives worse size_hints than filter_map today (#48544) and has more complicated code (needs to keep the iterator in its state after giving out an item, since unlike Option it doesn't know if that's the only item), so that's potentially a pessimization.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-cleanupCategory: PRs that clean code up or issues documenting cleanup.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@scottmcm@rust-highfive@jyn514@estebank@bors@shepmaster@rustbot