Koskamo

Ownership and borrowing with references

Document v1 · published by Koskamo editorial · updated 2026-10-04

Original source

References let you use a value without taking ownership of it: the & syntax creates a reference, and the action of creating one is called borrowing. Because a reference does not own the value, the value is not dropped when the reference goes out of scope, so a function taking a reference parameter never has to return the value to hand ownership back. References are immutable by default — you cannot modify something you only have a & reference to; use &mut for a mutable reference, which makes the mutation intent explicit in the signature. A mutable reference is exclusive: while one exists you can have no other references to that value, mutable or immutable, and this restriction lets Rust prevent data races at compile time. A reference's scope runs from its introduction to its last use, so non-overlapping scopes let a mutable reference follow immutable ones. The compiler also guarantees references are never dangling. The rules: at any given time, either one mutable reference or any number of immutable references, and references must always be valid. Scope: Rust. Reviewed October 4, 2026.

Source and provenance

Original source
doc.rust-lang.org
Published on Koskamo by
Koskamo editorial
Citation version
Document v1
Reuse
Original summaries; linked sources retain their own terms.

The original source supplies the underlying information. Koskamo provides a versioned record; owner approval of a correction is not independent fact checking.