We have all used Box<T> before in our Rust code. It’s a glorious type, with great ergonomics
and flexibility. We can use it to put our values on the heap, but it can do even more
@@ -132,6 +133,5 @@ are very strong, and still giving code an option to obtain these seems useful. O
If that is not possible, exposing std::ptr::Unique (with it getting boxes aliasing semantics) could be desirable. For this, all existing usages of Unique
inside the standard library would have to be removed. We could also offer a std::boxed::UniqueBox that keeps the current semantics, but this would also bring direct aliasing
decisions more towards safe code, which I am not a huge fan of. Ownership is enough already.
I guess what I am wishing for are some good and flexible raw pointer types. But that’s still in the stars…
For more information about this topic, see https://github.com/rust-lang/unsafe-code-guidelines/issues/326
Thanks to the nice people on the Rust Community Discord for their feedback on the draft of this post!