Unit content
Ownership, borrowing and lifetimes
An ownership type discipline gives each resource a distinguished owner and controls temporary aliases through borrowing.
Moving an owned value transfers the right to use it:
b = move(a)
After the move, using a is rejected because two independent owners would allow conflicting destruction or mutation.
A shared borrow grants temporary read access without transferring ownership. Several shared borrows can coexist when mutation is forbidden. An exclusive borrow grants temporary mutable access and excludes other simultaneous accesses that could conflict.
A lifetime describes the region of execution during which a borrowed reference must remain valid. A reference may not outlive the storage it refers to. Conceptually, if a function returns a reference into a local value that is destroyed on return, the lifetime constraints cannot be satisfied.
These rules turn aliasing restrictions into static invariants. They can prevent use-after-free, double destruction and many data races without requiring tracing garbage collection.
Ownership is not identical to linear typing, but affine ideas provide a natural foundation: owned capabilities are not freely duplicable, while borrowing creates controlled temporary access that must end before conflicting access resumes.