@@ -41,7 +41,7 @@ pub type LabelId = Idx<Label>;
41
41
#[ derive( Debug , Clone , Eq , PartialEq ) ]
42
42
pub enum Literal {
43
43
String ( String ) ,
44
- ByteString ( Vec < u8 > ) ,
44
+ ByteString ( Box < [ u8 ] > ) ,
45
45
Char ( char ) ,
46
46
Bool ( bool ) ,
47
47
Int ( i128 , Option < BuiltinInt > ) ,
@@ -182,7 +182,7 @@ pub enum Expr {
182
182
183
183
#[ derive( Debug , Clone , Eq , PartialEq ) ]
184
184
pub enum Array {
185
- ElementList ( Vec < ExprId > ) ,
185
+ ElementList ( Box < [ ExprId ] > ) ,
186
186
Repeat { initializer : ExprId , repeat : ExprId } ,
187
187
}
188
188
@@ -228,23 +228,23 @@ impl Expr {
228
228
Expr :: If { condition, then_branch, else_branch } => {
229
229
f ( * condition) ;
230
230
f ( * then_branch) ;
231
- if let Some ( else_branch) = else_branch {
232
- f ( * else_branch) ;
231
+ if let & Some ( else_branch) = else_branch {
232
+ f ( else_branch) ;
233
233
}
234
234
}
235
235
Expr :: Block { statements, tail, .. } => {
236
236
for stmt in statements. iter ( ) {
237
237
match stmt {
238
238
Statement :: Let { initializer, .. } => {
239
- if let Some ( expr) = initializer {
240
- f ( * expr) ;
239
+ if let & Some ( expr) = initializer {
240
+ f ( expr) ;
241
241
}
242
242
}
243
243
Statement :: Expr { expr : expression, .. } => f ( * expression) ,
244
244
}
245
245
}
246
- if let Some ( expr) = tail {
247
- f ( * expr) ;
246
+ if let & Some ( expr) = tail {
247
+ f ( expr) ;
248
248
}
249
249
}
250
250
Expr :: TryBlock { body }
@@ -262,34 +262,28 @@ impl Expr {
262
262
}
263
263
Expr :: Call { callee, args } => {
264
264
f ( * callee) ;
265
- for arg in args. iter ( ) {
266
- f ( * arg) ;
267
- }
265
+ args. iter ( ) . copied ( ) . for_each ( f) ;
268
266
}
269
267
Expr :: MethodCall { receiver, args, .. } => {
270
268
f ( * receiver) ;
271
- for arg in args. iter ( ) {
272
- f ( * arg) ;
273
- }
269
+ args. iter ( ) . copied ( ) . for_each ( f) ;
274
270
}
275
271
Expr :: Match { expr, arms } => {
276
272
f ( * expr) ;
277
- for arm in arms. iter ( ) {
278
- f ( arm. expr ) ;
279
- }
273
+ arms. iter ( ) . map ( |arm| arm. expr ) . for_each ( f) ;
280
274
}
281
275
Expr :: Continue { .. } => { }
282
276
Expr :: Break { expr, .. } | Expr :: Return { expr } | Expr :: Yield { expr } => {
283
- if let Some ( expr) = expr {
284
- f ( * expr) ;
277
+ if let & Some ( expr) = expr {
278
+ f ( expr) ;
285
279
}
286
280
}
287
281
Expr :: RecordLit { fields, spread, .. } => {
288
282
for field in fields. iter ( ) {
289
283
f ( field. expr ) ;
290
284
}
291
- if let Some ( expr) = spread {
292
- f ( * expr) ;
285
+ if let & Some ( expr) = spread {
286
+ f ( expr) ;
293
287
}
294
288
}
295
289
Expr :: Lambda { body, .. } => {
@@ -300,11 +294,11 @@ impl Expr {
300
294
f ( * rhs) ;
301
295
}
302
296
Expr :: Range { lhs, rhs, .. } => {
303
- if let Some ( lhs) = rhs {
304
- f ( * lhs) ;
297
+ if let & Some ( lhs) = rhs {
298
+ f ( lhs) ;
305
299
}
306
- if let Some ( rhs) = lhs {
307
- f ( * rhs) ;
300
+ if let & Some ( rhs) = lhs {
301
+ f ( rhs) ;
308
302
}
309
303
}
310
304
Expr :: Index { base, index } => {
@@ -320,17 +314,9 @@ impl Expr {
320
314
| Expr :: Box { expr } => {
321
315
f ( * expr) ;
322
316
}
323
- Expr :: Tuple { exprs } => {
324
- for expr in exprs. iter ( ) {
325
- f ( * expr) ;
326
- }
327
- }
317
+ Expr :: Tuple { exprs } => exprs. iter ( ) . copied ( ) . for_each ( f) ,
328
318
Expr :: Array ( a) => match a {
329
- Array :: ElementList ( exprs) => {
330
- for expr in exprs {
331
- f ( * expr) ;
332
- }
333
- }
319
+ Array :: ElementList ( exprs) => exprs. iter ( ) . copied ( ) . for_each ( f) ,
334
320
Array :: Repeat { initializer, repeat } => {
335
321
f ( * initializer) ;
336
322
f ( * repeat)
@@ -386,15 +372,15 @@ pub struct RecordFieldPat {
386
372
pub enum Pat {
387
373
Missing ,
388
374
Wild ,
389
- Tuple { args : Vec < PatId > , ellipsis : Option < usize > } ,
390
- Or ( Vec < PatId > ) ,
391
- Record { path : Option < Box < Path > > , args : Vec < RecordFieldPat > , ellipsis : bool } ,
375
+ Tuple { args : Box < [ PatId ] > , ellipsis : Option < usize > } ,
376
+ Or ( Box < [ PatId ] > ) ,
377
+ Record { path : Option < Box < Path > > , args : Box < [ RecordFieldPat ] > , ellipsis : bool } ,
392
378
Range { start : ExprId , end : ExprId } ,
393
- Slice { prefix : Vec < PatId > , slice : Option < PatId > , suffix : Vec < PatId > } ,
379
+ Slice { prefix : Box < [ PatId ] > , slice : Option < PatId > , suffix : Box < [ PatId ] > } ,
394
380
Path ( Box < Path > ) ,
395
381
Lit ( ExprId ) ,
396
382
Bind { mode : BindingAnnotation , name : Name , subpat : Option < PatId > } ,
397
- TupleStruct { path : Option < Box < Path > > , args : Vec < PatId > , ellipsis : Option < usize > } ,
383
+ TupleStruct { path : Option < Box < Path > > , args : Box < [ PatId ] > , ellipsis : Option < usize > } ,
398
384
Ref { pat : PatId , mutability : Mutability } ,
399
385
Box { inner : PatId } ,
400
386
ConstBlock ( ExprId ) ,
0 commit comments