Skip to content

Commit c1455c0

Browse files
committed
update unstable book to mention moving out of boxes
1 parent 85d918c commit c1455c0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/doc/unstable-book/src/language-features/deref-patterns.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The tracking issue for this feature is: [#87121]
77
------------------------
88

99
> **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`].
1111
1212
This feature permits pattern matching on [smart pointers in the standard library] through their
1313
`Deref` target types, either implicitly or with explicit `deref!(_)` patterns (the syntax of which
@@ -54,4 +54,17 @@ if let [b] = &mut *v {
5454
assert_eq!(v, [Box::new(Some(2))]);
5555
```
5656

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
5770
[smart pointers in the standard library]: https://doc.rust-lang.org/std/ops/trait.DerefPure.html#implementors

0 commit comments

Comments
 (0)