5 ms·
I've been wondering if it would make sense to encapsulate internal fields that are part of the unsafe machinery in a type forcing you to use unsafe blocks, even
by phaylon 11y ago
I've been wondering if it would make sense to encapsulate internal fields that are part of the unsafe machinery in a type forcing you to use unsafe blocks, even inside the type impl. [edit: Removed note about UnsafeCell since it's not really like the thing described above]
I haven't really played with it though, most of my unsafe use is FFI.
- Manishearth 11y agoYou can, but IMO it's not so necessary. The module boundary thing doesn't cause many issues in practice is straightforward to reason about if you're aware of it. (And if you weren't aware of it you would probably not use `UnsafeField` either, since the compiler can't force you to do that)
- phaylon 11y agoI'm more thinking about the documentation effect of such a wrapper type. Both in the data structure and in the parts of the code that are foced to use unsafe.
- ralfj 11y agoI suggested something kind-of-similar at <https://internals.rust-lang.org/t/pre-rfc-unsafe-types/3073> https://internals.rust-lang.org/t/pre-rfc-unsafe-types/3073>