So, I just finished Chapter 10 (Generic Types, Traits, and Lifetimes). There's paragraph from third part:
When annotating lifetimes in functions, the annotations go in the function signature, not in the function body. Rust can analyze the code within the function without any help. However, when a function has references to or from code outside that function, it becomes almost impossible for Rust to figure out the lifetimes of the parameters or return values on its own. The lifetimes might be different each time the function is called. This is why we need to annotate the lifetimes manually.
I do not understand it at all. Why it is almost impossible? Instead of using a function we could extract code from its body and use this code directly in place we call this function. Borrow checker still will be able to work and point dangle reference problem, if there any, and, at the same time, we don't have to specify lifetimes. Program, in fact, will be the same (except bigger and harder to read).