Skip to content

Commit 8ce4449

Browse files
committed
Expand example somewhat with regular field
1 parent 8927082 commit 8ce4449

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

text/0000-manually-drop.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ impl<T> ManuallyDrop<T> {
105105
// Other common impls such as `Debug for T: Debug`.
106106
```
107107

108-
Let us apply this union to the example from the motivation:
108+
Let us apply this union to a somewhat expanded example from the motivation:
109109

110110
```rust
111111
struct FruitBox {
112112
// Immediately clear there’s something non-trivial going on with these fields.
113113
peach: ManuallyDrop<Peach>,
114+
melon: Melon, // Field that’s independent of the other two.
114115
banana: ManuallyDrop<Banana>,
115116
}
116117

@@ -123,6 +124,8 @@ impl Drop for FruitBox {
123124
peach.manually_drop();
124125
banana.manually_drop();
125126
}
127+
// After destructor for `FruitBox` runs (this function), the destructor for Melon gets
128+
// invoked in the usual manner, as it is not wrapped in `ManuallyDrop`.
126129
}
127130
}
128131
```

0 commit comments

Comments
 (0)