@@ -334,14 +334,14 @@ anyway is that the current behavior is unintuitive and surprising for users.
334
334
335
335
``` rust
336
336
// ! All editions: works only with this rule
337
- let & [[ a ]] = & [ & mut [42 ]] ; // x: & i32
337
+ let & ( i , j , [ s ]) = & ( 63 , 42 , & mut [String :: from ( " 🦀 " )]) ; // i: i32, j: i32, s: &String
338
338
```
339
339
340
340
``` rust
341
341
// ! All editions: works with or without this rule (alternative to above)
342
- // Note the explicit `ref`, we must abandon match ergonomics
343
- let & [[ ref a ]] = & [ & mut [42 ]] ; // x: & i32
344
- let & [ & mut [ref a ]] = & [ & mut [42 ]] ; // x: & i32
342
+ let ( & i , & j , [ s ]) = & ( 42 , & mut [ String :: from ( " 🦀 " )]); // i: i32, j: i32, s: &String
343
+ let & ( i , j , [ ref s ]) = & ( 42 , & mut [String :: from ( " 🦀 " )]) ; // i: i32, j: i32, s: &String
344
+ let & ( i , j , & mut [ref s ]) = & ( 42 , & mut [String :: from ( " 🦀 " )]) ; // i: i32, j: i32, s: &String
345
345
```
346
346
347
347
#### Patterns that work only without this rule
@@ -356,7 +356,6 @@ let &[[&mut a]] = &[&mut [42]]; // x: i32
356
356
357
357
``` rust
358
358
// ! Edition ≥ 2024: works with or without this rule (alternatives to above)
359
- // No need to abandon match ergonomics
360
359
let & [[& a ]] = & [& mut [42 ]]; // x: i32
361
360
let & [& mut [a ]] = & [& mut [42 ]]; // x: i32
362
361
```
@@ -468,8 +467,8 @@ concerns with certain proposals for "deref patterns".
468
467
[ future-possibilities ] : #future-possibilities
469
468
470
469
- An explicit syntax for mutable by-reference bindings should be chosen at some
471
- point, along with removing the prohibition on implicitly by-reference
472
- mutable bindings.
470
+ point, along with removing the prohibition on implicitly by-reference mutable
471
+ bindings.
473
472
- Future changes to reference types (partial borrows, language sugar for ` Pin ` ,
474
473
etc) may interact with match ergonomics.
475
474
@@ -484,8 +483,7 @@ question that would need to be resolved is whether and how deref patterns
484
483
## Matching ` &mut ` behind ` & `
485
484
486
485
There is one notable situation where match ergonomics cannot be used, and
487
- explicit ` ref ` is required. Notably, this can occur where ` &mut ` is nested
488
- behind ` & ` :
486
+ explicit ` ref ` is required. This happens where ` &mut ` is nested behind ` & ` :
489
487
490
488
``` rust
491
489
// No way to avoid the `ref`, even with this RFC
0 commit comments