Skip to content

Commit 8eb4f09

Browse files
committed
Update partially initialized values in drop documentation.
1 parent 1528956 commit 8eb4f09

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/destructors.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
When an [initialized] [variable] in Rust goes out of scope or a [temporary]
44
is no longer needed its _destructor_ is run. [Assignment] also runs the
55
destructor of its left-hand operand, unless it's an uninitialized variable. If a
6-
[struct] variable has been partially initialized, only its initialized fields
7-
are dropped.
6+
variable has been partially initialized, only its initialized fields are
7+
dropped.
88

99
The destructor of a type consists of
1010

@@ -63,10 +63,11 @@ loop {
6363
moved = ShowOnDrop("Drops when moved");
6464
// drops now, but is then uninitialized
6565
moved;
66+
// Uninitialized does not drop.
6667
let uninitialized: ShowOnDrop;
6768
// Only first element drops
68-
let mut partially_initialized: (ShowOnDrop, ShowOnDrop);
69-
partially_initialized.0 = ShowOnDrop("Partial tuple first");
69+
let mut partially_initialized = (ShowOnDrop("one"), ShowOnDrop("two"));
70+
core::mem::forget(partially_initialized.1);
7071
}
7172
```
7273

0 commit comments

Comments
 (0)