Skip to content

Commit

Permalink
Remove partially initialized values from drop documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Aug 6, 2019
1 parent 1528956 commit e3966e5
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/destructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

When an [initialized] [variable] in Rust goes out of scope or a [temporary]
is no longer needed its _destructor_ is run. [Assignment] also runs the
destructor of its left-hand operand, unless it's an uninitialized variable. If a
[struct] variable has been partially initialized, only its initialized fields
are dropped.
destructor of its left-hand operand, unless it's an uninitialized variable.

The destructor of a type consists of

Expand Down Expand Up @@ -63,10 +61,8 @@ 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");
}
```

Expand Down

0 comments on commit e3966e5

Please sign in to comment.