diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-08-08 22:44:15 +0200 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-08-08 22:44:15 +0200 |
commit | 22675cd8dc75d8b8d4b0f818f5b093efbc364802 (patch) | |
tree | 90156d37dccf13f012d535e7d92273259e3d5c17 /Ownership.md | |
parent | 295b343aecf330e830d79f06e0efc511e7d76da1 (diff) |
Diffstat (limited to 'Ownership.md')
-rw-r--r-- | Ownership.md | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Ownership.md b/Ownership.md index 5484772..772153f 100644 --- a/Ownership.md +++ b/Ownership.md @@ -1,14 +1,16 @@ [[Rust]] -[[When boxes are deallocated]] +[[When heap data is 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. +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. +[[Passing a pointer to heap data as an argument to a function transfers its ownership]] + ![[Pasted image 20250804184242.png]] > Wherever the stack variable is greyed out means it is no longer the owner.
\ No newline at end of file |