Recently, I wrote on reddit that a Rust book won’t become obsolete in the next years if it focused on explaining concepts instead of current APIs. At basically the same time, I tried to explain some of Rust’s concepts to a friend. I think I came up with a quite concise description (maybe even explanation) of “ownership and borrowing” (the concept that differentiates Rust from most other programming language).


Ownership: You own a resource, and when you are done with it, that resource is no longer in scope and gets deallocated.

References to a resource depend on the lifetime of that resource (i.e., they are only valid until the resource is deallocated).

Move semantics means: Giving an owned resource to a function means giving it away. You can no longer access it.

To not move a resource, you instead use borrowing: You create a reference to it and move that. When you create a reference, you own that reference. Then you move it (and ownership of it) to the function you call. (Nothing new, just both concepts at the same time.)

To manipulate a resource without giving up ownership, you can create one mutable reference. During the lifetime of this reference, no other references to the same resource can exist.

That’s it. And it’s all checked at compile-time.