Ownership
202307101925
Status: #idea
Tags: Rust
Ownership
- Allows Rust to make memory safety guarantees without having a garbage collector
- Rust does not check at runtime whether a variable is defined before it is used. Instead, Rust checks at compile time
Rust's Goals w.r.t. Ownership
The Rust Model of Memory
Summary
- All heap data must be owned by exactly one variable
- Rust deallocates heap data once its owner goes out of scope
- Ownership can be transferred by moves. Which occurs during assignments and function calls
- Heap data can only be accessed through its current owner