Skip to content
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

Replace iterator structures with impl Trait. #48699

Merged
merged 2 commits into from
Mar 9, 2018

Conversation

frewsxcv
Copy link
Member

@frewsxcv frewsxcv commented Mar 3, 2018

Two commits:

  • Replace iterator structures with impl Trait.
  • Run rustfmt on src/librustc_data_structures/graph/mod.rs.

@rust-highfive
Copy link
Contributor

r? @nikomatsakis

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 3, 2018
@frewsxcv frewsxcv changed the title Replace iterator structurese with impl Trait. Replace iterator structures with impl Trait. Mar 3, 2018
@aravind-pg aravind-pg requested review from arielb1 and removed request for arielb1 March 3, 2018 20:22
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Nice cleanup! Let's go ahead and do the other cases, too!

self.edges
.iter()
.enumerate()
.map(|(idx, e)| (EdgeIndex(idx), e))
}

pub fn each_node<'a, F>(&'a self, mut f: F) -> bool
Copy link
Contributor

Choose a reason for hiding this comment

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

This can use impl trait too -- mut f: impl FnMut(NodeIndex, &'a Node<N>) -> bool

{
//! Iterates over all edges defined in the graph.
self.enumerated_nodes().all(|(node_idx, node)| f(node_idx, node))
self.enumerated_nodes()
.all(|(node_idx, node)| f(node_idx, node))
}

pub fn each_edge<'a, F>(&'a self, mut f: F) -> bool
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@frewsxcv frewsxcv force-pushed the frewsxcv-impl-trait branch from 588f88f to d8172b0 Compare March 7, 2018 01:49
@frewsxcv
Copy link
Member Author

frewsxcv commented Mar 7, 2018

@nikomatsakis comments have been addressed!

@nikomatsakis
Copy link
Contributor

@frewsxcv

there are travis errors here, I think because we need to remove a now unused type parameter (which was migrated to an impl Trait usage) -- at least that would be my guess

pub fn each_node<'a, F>(&'a self, mut f: F) -> bool
where F: FnMut(NodeIndex, &'a Node<N>) -> bool
{
pub fn each_node<'a, F>(&'a self, mut f: impl FnMut(NodeIndex, &'a Node<N>) -> bool) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

F is not used

pub fn each_edge<'a, F>(&'a self, mut f: F) -> bool
where F: FnMut(EdgeIndex, &'a Edge<E>) -> bool
{
pub fn each_edge<'a, F>(&'a self, mut f: impl FnMut(EdgeIndex, &'a Edge<E>) -> bool) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@frewsxcv frewsxcv force-pushed the frewsxcv-impl-trait branch from d8172b0 to 08a0182 Compare March 8, 2018 01:10
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 8, 2018

📌 Commit 08a0182 has been approved by nikomatsakis

@bors bors 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 Mar 8, 2018
@Manishearth Manishearth dismissed nikomatsakis’s stale review March 8, 2018 19:24

(changes addressed)

Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 8, 2018
…omatsakis

Replace iterator structures with `impl Trait`.

Two commits:

* Replace iterator structures with `impl Trait`.
* Run rustfmt on `src/librustc_data_structures/graph/mod.rs`.
bors added a commit that referenced this pull request Mar 8, 2018
Rollup of 7 pull requests

- Successful merges: #48292, #48682, #48699, #48738, #48752, #48789, #48808
- Failed merges:
@bors bors merged commit 08a0182 into rust-lang:master Mar 9, 2018
@frewsxcv frewsxcv deleted the frewsxcv-impl-trait branch March 11, 2018 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants