rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Add new assist to convert for loop with while let

Open arshiamoeini opened this issue 3 years ago • 2 comments

Application

With this assist the users can convert their for to while let so that they can iterate their list manually.

For example, we have a text that we iterate by its iterator. If we come across the word a, then we are waiting for b after that, so we skip the iterator:

fn main() {
    let v = [1, 2, 3, 4];
    let mut v = v.into_iter();
    while let Some(x) = v.next() {
        if x == "a" {
            v.skip(1);
        }
    }
}

arshiamoeini avatar Aug 24 '22 20:08 arshiamoeini

Cool!!

ice1000 avatar Aug 26 '22 14:08 ice1000

:umbrella: The latest upstream changes (presumably #13091) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Sep 05 '22 11:09 bors

Can you remove the merge commits of the PR please? (Either by rebasing somehow or opening a new PR with the changes on a new branch) These merge commits create a lot of noise in the commit graph otherwise.

Veykril avatar Jan 09 '23 12:01 Veykril

:umbrella: The latest upstream changes (presumably #13935) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Jan 16 '23 19:01 bors

Closing this due to inactivity, feel free to re-open should you come back to it.

Veykril avatar Mar 15 '23 11:03 Veykril