@@ -65,10 +65,7 @@ impl InsertionList {
65
65
}
66
66
67
67
fn is_block ( body : & ExprOrBlock ) -> bool {
68
- match body {
69
- ExprOrBlock :: Block ( _) => { true }
70
- ExprOrBlock :: Expr ( _) => { false }
71
- }
68
+ return matches ! ( body, ExprOrBlock :: Block ( _) ) ;
72
69
}
73
70
74
71
fn make_start_fn_insertion ( offset : TextSize ) -> Insertion {
@@ -165,15 +162,13 @@ fn add_all_variables_from_declaration(patterns: impl Iterator<Item = impl Borrow
165
162
p. name ( ) . map ( |name| ret. add_variable ( name. to_string ( ) ) ) ;
166
163
} ,
167
164
Pattern :: RestPattern ( p) => {
168
- let pat = p. pat ( ) ;
169
- if pat. is_some ( ) {
170
- ret. append ( & mut add_all_variables_from_declaration ( [ & pat. unwrap ( ) ] . into_iter ( ) ) ) ;
165
+ if let Some ( pat) = p. pat ( ) {
166
+ ret. append ( & mut add_all_variables_from_declaration ( [ & pat] . into_iter ( ) ) ) ;
171
167
}
172
168
} ,
173
169
Pattern :: AssignPattern ( p) => {
174
- let key = p. key ( ) ;
175
- if key. is_some ( ) {
176
- ret. append ( & mut add_all_variables_from_declaration ( [ & key. unwrap ( ) ] . into_iter ( ) ) ) ;
170
+ if let Some ( key) = p. key ( ) {
171
+ ret. append ( & mut add_all_variables_from_declaration ( [ & key] . into_iter ( ) ) ) ;
177
172
}
178
173
} ,
179
174
Pattern :: ObjectPattern ( p) => {
@@ -183,8 +178,8 @@ fn add_all_variables_from_declaration(patterns: impl Iterator<Item = impl Borrow
183
178
ret. append ( & mut add_all_variables_from_declaration ( [ & Pattern :: AssignPattern ( p) ] . into_iter ( ) ) ) ;
184
179
}
185
180
ObjectPatternProp :: KeyValuePattern ( p) => {
186
- if p . key ( ) . is_some ( ) {
187
- match p . key ( ) . unwrap ( ) {
181
+ if let Some ( key ) = p . key ( ) {
182
+ match key {
188
183
PropName :: Ident ( ident) => {
189
184
ret. add_variable ( ident. text ( ) ) ;
190
185
}
@@ -276,12 +271,12 @@ fn collect_insertions(node: &SyntaxNode, nesting_depth: u32) -> InsertionList {
276
271
if ExprStmt :: can_cast ( child. kind ( ) ) && !has_function_parent {
277
272
let as_expr_stmt = ExprStmt :: cast ( child) . unwrap ( ) ;
278
273
let expr_range = as_expr_stmt. expr ( ) . map ( |e| e. syntax ( ) . text_range ( ) ) ;
279
- if expr_range. is_some ( ) {
280
- insertions. push_back ( Insertion :: new ( expr_range . unwrap ( ) . start ( ) , "_cr = (" ) ) ;
274
+ if let Some ( start ) = expr_range. map ( |r| r . start ( ) ) {
275
+ insertions. push_back ( Insertion :: new ( start, "_cr = (" ) ) ;
281
276
}
282
277
insertions. append ( child_insertions) ;
283
- if expr_range. is_some ( ) {
284
- insertions. push_back ( Insertion :: new ( expr_range . unwrap ( ) . end ( ) , ")" ) ) ;
278
+ if let Some ( end ) = expr_range. map ( |r| r . end ( ) ) {
279
+ insertions. push_back ( Insertion :: new ( end, ")" ) ) ;
285
280
}
286
281
continue ;
287
282
}
0 commit comments