diff options
Diffstat (limited to 'crates/ide_assists/src')
-rw-r--r-- | crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs index 7e6cae9e1..661a3fbeb 100644 --- a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs +++ b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs | |||
@@ -6,27 +6,27 @@ use syntax::{ | |||
6 | 6 | ||
7 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 7 | use crate::{AssistContext, AssistId, AssistKind, Assists}; |
8 | 8 | ||
9 | /// Assist: convert_iter_for_each_to_for | 9 | // Assist: convert_iter_for_each_to_for |
10 | // | 10 | // |
11 | /// Converts an Iterator::for_each function into a for loop. | 11 | // Converts an Iterator::for_each function into a for loop. |
12 | /// | 12 | // |
13 | /// ```rust | 13 | // ```rust |
14 | /// fn main() { | 14 | // fn main() { |
15 | /// let vec = vec![(1, 2), (2, 3), (3, 4)]; | 15 | // let vec = vec![(1, 2), (2, 3), (3, 4)]; |
16 | /// x.iter().for_each(|(x, y)| { | 16 | // x.iter().for_each(|(x, y)| { |
17 | /// println!("x: {}, y: {}", x, y); | 17 | // println!("x: {}, y: {}", x, y); |
18 | /// }) | 18 | // }); |
19 | /// } | 19 | // } |
20 | /// ``` | 20 | // ``` |
21 | /// -> | 21 | // -> |
22 | /// ```rust | 22 | // ```rust |
23 | /// fn main() { | 23 | // fn main() { |
24 | /// let vec = vec![(1, 2), (2, 3), (3, 4)]; | 24 | // let vec = vec![(1, 2), (2, 3), (3, 4)]; |
25 | /// for (x, y) in x.iter() { | 25 | // for (x, y) in x.iter() { |
26 | /// println!("x: {}, y: {}", x, y); | 26 | // println!("x: {}, y: {}", x, y); |
27 | /// }); | 27 | // } |
28 | /// } | 28 | // } |
29 | /// ``` | 29 | // ``` |
30 | pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 30 | pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
31 | let method = ctx.find_node_at_offset::<ast::MethodCallExpr>()?; | 31 | let method = ctx.find_node_at_offset::<ast::MethodCallExpr>()?; |
32 | let stmt = method.syntax().parent().and_then(ast::ExprStmt::cast); | 32 | let stmt = method.syntax().parent().and_then(ast::ExprStmt::cast); |