File tree 1 file changed +14
-1
lines changed
src/doc/unstable-book/src/language-features
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ The tracking issue for this feature is: [#87121]
7
7
------------------------
8
8
9
9
> ** Note** : This feature is incomplete. In the future, it is meant to supersede
10
- > [ ` box_patterns ` ] ( ./box-patterns.md ) and [ ` string_deref_patterns ` ] ( ./string-deref-patterns.md ) .
10
+ > [ ` box_patterns ` ] and [ ` string_deref_patterns ` ] .
11
11
12
12
This feature permits pattern matching on [ smart pointers in the standard library] through their
13
13
` Deref ` target types, either implicitly or with explicit ` deref!(_) ` patterns (the syntax of which
@@ -54,4 +54,17 @@ if let [b] = &mut *v {
54
54
assert_eq! (v , [Box :: new (Some (2 ))]);
55
55
```
56
56
57
+ Like [ ` box_patterns ` ] , deref patterns may move out of boxes:
58
+
59
+ ``` rust
60
+ # #![feature(deref_patterns)]
61
+ # #![allow(incomplete_features)]
62
+ struct NoCopy ;
63
+ // Match exhaustiveness analysis is not yet implemented.
64
+ let deref! (x ) = Box :: new (NoCopy ) else { unreachable! () };
65
+ drop :: <NoCopy >(x );
66
+ ```
67
+
68
+ [ `box_patterns` ] : ./box-patterns.md
69
+ [ `string_deref_patterns` ] : ./string-deref-patterns.md
57
70
[ smart pointers in the standard library ] : https://doc.rust-lang.org/std/ops/trait.DerefPure.html#implementors
You can’t perform that action at this time.
0 commit comments