We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e922989 + a5b0281 commit b4b3536Copy full SHA for b4b3536
src/destructors.md
@@ -63,10 +63,15 @@ loop {
63
moved = ShowOnDrop("Drops when moved");
64
// drops now, but is then uninitialized
65
moved;
66
+
67
+ // Uninitialized does not drop.
68
let uninitialized: ShowOnDrop;
- // Only first element drops
- let mut partially_initialized: (ShowOnDrop, ShowOnDrop);
69
- partially_initialized.0 = ShowOnDrop("Partial tuple first");
70
+ // After a partial move, only the remaining fields are dropped.
71
+ let mut partial_move = (ShowOnDrop("first"), ShowOnDrop("forgotten"));
72
+ // Perform a partial move, leaving only `partial_move.0` initialized.
73
+ core::mem::forget(partial_move.1);
74
+ // When partial_move's scope ends, only the first field is dropped.
75
}
76
```
77
0 commit comments