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

Remove Iterator::advance #15492

Closed
bluss opened this issue Jul 7, 2014 · 4 comments
Closed

Remove Iterator::advance #15492

bluss opened this issue Jul 7, 2014 · 4 comments

Comments

@bluss
Copy link
Member

bluss commented Jul 7, 2014

Unless I'm confused, Iterator::advance is actually exactly equivalent to Iterator::all.

We thus have two good reasons to remove it, 1) It's a legacy protocol 2) It's got an exact replacement in .all()

@ftxqxd
Copy link
Contributor

ftxqxd commented Jul 7, 2014

Iterator::advance stops iterating at the first occurrence of a false value, while Iterator::all iterates over the entire iterator before stopping.

@huonw
Copy link
Member

huonw commented Jul 7, 2014

Yes, this should go.

@P1start no, both short-circuit. They are identical, the only difference is advance is written without the for, since it existed from before our new for protocol, and was the interface between the old and new iteration (for v.iter().advance |x| { ... }).

    fn advance(&mut self, f: |A| -> bool) -> bool {
        loop {
            match self.next() {
                Some(x) => {
                    if !f(x) { return false; }
                }
                None => { return true; }
            }
        }
    }

    fn all(&mut self, f: |A| -> bool) -> bool {
        for x in *self { if !f(x) { return false; } }
        true
    }

@huonw huonw added the A-libs label Jul 7, 2014
@luqmana
Copy link
Member

luqmana commented Jul 7, 2014

I actually had I branch I was working on that I kinda forgot about (https://github.com/luqmana/rust/commits/die-advance-die) I'll update it and push it out.

@bluss
Copy link
Member Author

bluss commented Jul 7, 2014

@luqmana cool! It looks though as you can use .all() instead of explicit loops in many of your diff hunks.

@bors bors closed this as completed in 1b8e671 Jul 10, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 13, 2023
extend check.overrideCommand and buildScripts.overrideCommand docs

Extend check.overrideCommand and buildScripts.overrideCommand docs regarding invocation strategy and location.

However something still seems a bit odd -- the docs for `invocationStrategy`/`invocationLocation` talk about "workspaces", but the setting that controls which workspaces are considered is called `linkedProjects`. Is a project the same as a workspace here or is there some subtle difference?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants