|
|
|
|
|
by Jhsto
3910 days ago
|
|
Not sure is it like this anymore, but might be worth giving a read: > But allocating memory seemed like a fun exercise. To allocate something on the heap in Rust, you can do > let a = ~2 > This creates a pointer to a 2 on the heap. http://jvns.ca/blog/2014/03/12/the-rust-os-story/ |
|
> 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.