Skip to content

Commit e649309

Browse files
Expand on deref patterns
1 parent 0e1306b commit e649309

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

text/3627-match-ergonomics-2024.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ for users. Notably, the [property from earlier](#desirable-property) would
393393
continue to not be satisfied.
394394

395395
In addition, this approach would lead to tricky questions around when
396-
mutabilities should be considered compatible.
396+
mutabilities should be considered compatible. And there would be compatibility
397+
concerns with certain proposals for "deref patterns".
397398

398399
(This alternative is currently implemented under a separate feature gate.)
399400

@@ -409,10 +410,17 @@ mutabilities should be considered compatible.
409410

410411
- An explicit syntax for mutable by-reference bindings should be chosen at some
411412
point.
412-
- Deref patterns may interact with `&` and `&mut` patterns.
413413
- Future changes to reference types (partial borrows, language sugar for `Pin`,
414414
etc) may interact with match ergonomics.
415415

416+
## Deref patterns
417+
418+
Because it is compositional, the "eat-one-layer" model proposed by this RFC is
419+
fully compatible with proposals for "deref patterns", including allowing
420+
`&`/`&mut` patterns to match against types implementing `Deref`/`DerefMut`. One
421+
question that would need to be resolved is whether and how deref patterns
422+
(explicit or implicit) affect the default binding mode.
423+
416424
## Matching `&mut` behind `&`
417425

418426
There is one notable situation where match ergonomics cannot be used, and

0 commit comments

Comments
 (0)