Skip to content

Commit 0971718

Browse files
committed
unresolved question: move out of dropping union
1 parent 41a02cf commit 0971718

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

text/0000-union-initialization-and-drop.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,10 @@ we maybe try harder, e.g. lint against using `*` below a union type when
365365
describing a place? That would make people write `let v = &mut u.f; *v =
366366
Vec::new();`. It is not clear that this helps in terms of pointing out that an
367367
automatic drop may be happening.
368+
369+
We could allow moving out of a union field even if it implements `Drop`. That
370+
would have the effect of making the union considered uninitialized, i.e., it
371+
would not be dropped implicitly when it goes out of scope. However, it might be
372+
useful to not let people do this accidentally. The same effect can always be
373+
achieved by having a dropless union wrapped in a newtype `struct` with the
374+
desired `Drop`.

0 commit comments

Comments
 (0)