In the previous section, the word borrowed was mentioned in most error messages. What's this all about? What is the logic behind this borrow-checker mechanism?
Every program, whatever it does, whether reading data from a database or making a computation, is concerned with handling resources. The most common resource in a program is the memory space allocated to its variables. Other resources could be files, network connections, database connections, and so on. Every resource is given a name when we make a binding to it with
let; in Rust's language, we say that the resource gets an owner, for example, in the following code snippet,
klaatu owns a piece of memory that is taken up by the
Alien struct instance:
// see code in ...