The Algebra of Loans in Rust
4 months ago
- #Borrow-Checker
- #Rust
- #Memory-Safety
- Rust's borrow-checker restricts access to borrowed places until the borrow expires.
- New reference types like &own, &uninit, and pinning references are being discussed to enhance borrow-checking.
- &own T signifies full ownership over a value, including responsibility for dropping it.
- &uninit T refers to an allocated but uninitialized location, allowing only write operations.
- Pinning references (&pin T, &pin mut T, &pin own T) add a pinning requirement to prevent moving or deallocating without running Drop.
- Tables detail actions possible with each reference type and restrictions during and after loan expiration.