summaryrefslogtreecommitdiff
path: root/Ownership.md
diff options
context:
space:
mode:
authorJasper Ras <jras@hostnet.nl>2025-08-05 08:53:21 +0200
committerJasper Ras <jras@hostnet.nl>2025-08-05 08:53:21 +0200
commit295b343aecf330e830d79f06e0efc511e7d76da1 (patch)
tree85057ef1fe401adcd0d958ddf6ff966f25d8fef0 /Ownership.md
parentf43372529e655f3b039946c969e4465193eb2042 (diff)
vault backup: 2025-08-05 08:53:21
Diffstat (limited to 'Ownership.md')
-rw-r--r--Ownership.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/Ownership.md b/Ownership.md
new file mode 100644
index 0000000..5484772
--- /dev/null
+++ b/Ownership.md
@@ -0,0 +1,14 @@
+[[Rust]]
+[[When boxes are deallocated]]
+[[Moved heap data principle]]
+[[Creating a reference to a variable is called borrowing]]
+
+
+---
+
+When we assign a Box to a name we say that name owns the box. Any time we copy the pointer to that box to another name we also pass ownership to that name.
+
+After we pass ownership and move into a new scope the original variable is freed. Thus when we return to the original scope it is no longer possible to use it.
+
+![[Pasted image 20250804184242.png]]
+> Wherever the stack variable is greyed out means it is no longer the owner. \ No newline at end of file