-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
A-assistsS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right now
Description
Given the following code:
numbers // Vec<i32>
.into_iter()
.filter(|x| *x % 2 == 0)
.collect::<Vec<_>>()In VS Code, I want to select the predicate closure (|x| x % 2 == 0), click the yellow light bulb, and choose "Extract closure into function", and the code should turn into this:
numbers // Vec<i32>
.into_iter()
.filter(predicate)
.collect::<Vec<_>>()
fn predicate(x: &i32) -> bool {
*x % 2 == 0
}Note: The name predicate was deduced from the signature of the filter method. However, I wouldn't complain if rust-analyzer instead asks me for the name of the function.
Note: Currently, an option called "Extract into function" exists, but it only moves a whole expression to a new function. In regard to closure, the new function it creates is a function that returns closure, not the closure itself.
bmisiak, IndianBoy42, Skgland and joshka
Metadata
Metadata
Assignees
Labels
A-assistsS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right now