diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-08-05 08:53:21 +0200 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-08-05 08:53:21 +0200 |
commit | 295b343aecf330e830d79f06e0efc511e7d76da1 (patch) | |
tree | 85057ef1fe401adcd0d958ddf6ff966f25d8fef0 /Boxes live in the heap.md | |
parent | f43372529e655f3b039946c969e4465193eb2042 (diff) |
vault backup: 2025-08-05 08:53:21
Diffstat (limited to 'Boxes live in the heap.md')
-rw-r--r-- | Boxes live in the heap.md | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Boxes live in the heap.md b/Boxes live in the heap.md new file mode 100644 index 0000000..ec296c9 --- /dev/null +++ b/Boxes live in the heap.md @@ -0,0 +1,15 @@ +[[Rust]] +[[Variables lives in the stack]] +[[When boxes are deallocated]] +[[Ownership]] + +--- + +The heap is where data can live indefinitely and we can create pointers to it on the stack using a Box. + +```rust +let a = Box::new([0; 1_000_000]); +let b = a; +``` + +Creates an array with 1 million entries on the heap and two variables on the stack that point to it.
\ No newline at end of file |