3 ms·
> It's just a pointer" can also be said of `&T` & `&mut T But that's the point: you can assign your &T to a pointer and know that it won't be invalidated by me
by remram 3y ago
> It's just a pointer" can also be said of `&T` & `&mut T
But that's the point: you can assign your &T to a pointer and know that it won't be invalidated by merely moving the &T. That is not true for Box<T>.
- eddd-ddde 3y agoExcept is not the same thing? You can copy a reference, you can't copy a box (without having the T be copy as well). A box is a pointer AND the storage at the same time. To move it means to move the storage as well, unlike a regular reference.
- remram 3y ago> A box is a pointer AND the storage at the same time. That's just the way you decide to see it. Most people don't, in fact the actual documentation is quite different: >> A pointer type that uniquely owns a heap allocation of type T. This explicitly describes it as a pointer, pointing to a single allocation. https://doc.rust-lang.org/nightly/std/boxed/struct.Box.html https://doc.rust-lang.org/nightly/std/boxed/struct.Box.html