this post was submitted on 08 Oct 2023
66 points (92.3% liked)
Rust
5966 readers
32 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Box
is (basically) just the way to have memory on the heap. Here's a direct comparison of how to do heap memory in C/++ and in rust:There can be a bit more to it with custom allocators etc. but that's the only way most people will use boxes. So
Box
basically just means "aT
is allocated somewhere and we need to free that memory when this value is dropped".