Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/destructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@ loop {
moved = ShowOnDrop("Drops when moved");
// drops now, but is then uninitialized
moved;

// Uninitialized does not drop.
let uninitialized: ShowOnDrop;
// Only first element drops
let mut partially_initialized: (ShowOnDrop, ShowOnDrop);
partially_initialized.0 = ShowOnDrop("Partial tuple first");

// After a partial move, only the remaining fields are dropped.
let mut partial_move = (ShowOnDrop("first"), ShowOnDrop("forgotten"));
// Perform a partial move, leaving only `partial_move.0` initialized.
core::mem::forget(partial_move.1);
// When partial_move's scope ends, only the first field is dropped.
}
```

Expand Down