If you find this helpful, please like, bookmark, and follow. To keep learning along, follow this series. 10.5.1 What Is a Lifetime Every reference in Rust has its own lifetime. The purpose of a lifetime is to keep a reference valid; in other words, it is the scope during which a reference remains valid. In most cases, lifetimes are implicit and can be inferred. If the lifetimes of references may be related in different ways, you must annotate lifetimes manually. Lifetimes are probably the most distinctive feature of Rust compared with other languages, so they are very hard to learn. 10.5.2 Why Lifetimes Exist The main purpose of lifetimes is to avoid dangling references. This concept was already discussed in 4.4. Reference and Borrowing, and I’ll repeat the earlier explanation here: When using pointers, it is very easy to trigger an error called a Dangling Pointer .…