Stream: t-lang/wg-unsafe-code-guidelines

Topic: bitwise-movable trait to `Copy`

briansmith (Dec 10 2018 at 18:13, on Zulip):

Is there any hope for a new supertrait of Copythat means "safe to put in a union, and safe to transmute to an array of bytes, but cannot be implicitly copied?" I have stuff I want to put into unions that are semantically move-only (use-once) resources, and also I need the byte transmute transform and would prefer to be able to have the same restriction (bitwise movable but not implicitly copyable).

briansmith (Dec 10 2018 at 18:15, on Zulip):

My understanding from the DynSized discussion is that it's very hard to add such types, but the definition of union doesn't make sense without it. In particular, union requires too much use of unsafe; at least all the uses I have for it are completely safe w.r.t. what unsafe is trying to accomplish.

RalfJ (Dec 10 2018 at 21:53, on Zulip):

I don't follow. What would be examples of types that do not have this property?

Last update: Jul 14 2020 at 13:30UTC