3 ms·
That syntax has been changed, actually. Now, to allocated an owned pointer allocated on the heap, you use the Box type: > let a = Box::new(2); I believe it's
by zcdziura 11y ago
That syntax has been changed, actually. Now, to allocated an owned pointer allocated on the heap, you use the Box type:
> let a = Box::new(2);
I believe it's an unstable feature currently to use the "box" keyword to heap-allocate a value, which can also be used in pattern matching. I saw somewhere that "box" will be made into an overloadable operator, such that you can easily create reference-counted and atomically reference-counted types.
- steveklabnik 11y agoYes, that's generally correct. We still haven't fully decided on the exact syntax. If anyone wants to get involved, this RFC was the one that got merged, but hasn't been made stable yet: https://github.com/rust-lang/rfcs/blob/master/text/0809-box-and-in-for-stdlib.md https://github.com/rust-lang/rfcs/blob/master/text/0809-box-... And this is the active, in-final-comment-period one which modifies it: https://github.com/rust-lang/rfcs/pull/1228 https://github.com/rust-lang/rfcs/pull/1228