Commit 8eb4f09 1 parent 1528956 commit 8eb4f09 Copy full SHA for 8eb4f09
File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 3
3
When an [ initialized]   ; [ variable] in Rust goes out of scope or a [ temporary]
4
4
is no longer needed its _ destructor_ is run. [ Assignment] also runs the
5
5
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.
8
8
9
9
The destructor of a type consists of
10
10
@@ -63,10 +63,11 @@ loop {
63
63
moved = ShowOnDrop (" Drops when moved" );
64
64
// drops now, but is then uninitialized
65
65
moved ;
66
+ // Uninitialized does not drop.
66
67
let uninitialized : ShowOnDrop ;
67
68
// 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 );
70
71
}
71
72
```
72
73
You can’t perform that action at this time.
0 commit comments