summaryrefslogtreecommitdiff
path: root/Data must outlive any references to it.md
diff options
context:
space:
mode:
authorJasper Ras <jras@hostnet.nl>2025-08-08 22:44:15 +0200
committerJasper Ras <jras@hostnet.nl>2025-08-08 22:44:15 +0200
commit22675cd8dc75d8b8d4b0f818f5b093efbc364802 (patch)
tree90156d37dccf13f012d535e7d92273259e3d5c17 /Data must outlive any references to it.md
parent295b343aecf330e830d79f06e0efc511e7d76da1 (diff)
vault backup: 2025-08-08 22:44:15HEADmain
Diffstat (limited to 'Data must outlive any references to it.md')
-rw-r--r--Data must outlive any references to it.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/Data must outlive any references to it.md b/Data must outlive any references to it.md
new file mode 100644
index 0000000..162bf30
--- /dev/null
+++ b/Data must outlive any references to it.md
@@ -0,0 +1,14 @@
+[[Pointer safety principle]]
+[[Variables are subject to permissions similar to files on linux]]
+[[Lifetime specifier]]
+[[When heap data is deallocated]]
+[[Variables lives on the stack]]
+[[Ownership]]
+
+This is literally talking about heap data and references (ie `&String`): the heap data must not be freed when we try to use a reference to it.
+
+This is enforced in one of two ways.
+
+Firstly, if a reference is created to a variable it loses its Own permission: thus we can't drop it, because the compiler expects that permission on the place where it is dropped.
+
+Secondly, it uses the Flow permission and requires a a lifetime specifier when we return things from functions. \ No newline at end of file