Lifetimes are common in many languages and typically decide whether a variable is available outside the scope. In Rust, the situation is a bit more complicated thanks to the borrowing and ownership model that extensively uses lifetimes and scopes to automatically manage memory. Instead of reserving memory and cloning stuff into it, we developers want to avoid the inefficiencies and potential slowdowns this causes with references. However, this leads down a tricky path because, as the original value goes out of scope, what happens to the reference?
Since the compiler cannot infer this information from code, you have to help it and annotate the code so it can go and check for proper usage. Let's see what this looks like.