concept borrowing in category rust
appears as: borrowing

This is an excerpt from Manning's book Rust in Action.
The ampersand (
&) prefix tohaystackon line 5, e.g.&haystack, may look unfamiliar. The ampersand is acting as a unary operator that returns a reference tohaystack. For any typeT, the syntax&Treturns a read-only reference toT. A useful quirk of references to arrays is that they enable you to iterate over references to the elements of the array withforloops. In Rust terminology, when we use&Twe borrowT. A “borrowed” value outlives the scope that it is being used in. The concept of borrowing and its terminology are explained in detail during in chapter 4.
Borrow checking relies on three inter-related concepts: lifetimes, ownership and borrowing.