Borrowing notes

Borrowing is easiest to understand as a statement about relationships rather than punctuation. A reference says that some value remains owned elsewhere and that the current code may use it under a particular set of rules.

Ownership

Ownership makes resource lifetimes explicit without requiring a garbage collector. More importantly, it gives APIs a vocabulary for saying who may keep a value, who may change it, and when cleanup happens.

A useful question

When a lifetime annotation feels difficult, ask what relationship the returned value actually has to the inputs. The compiler is often pointing at an unclear contract rather than demanding more syntax.

Thanks for reading. If this sparked an idea, keep it moving. Browse the archive.