1. 40

I wrote a long, very basic introduction into Rust lifetimes. Happy to also answer any questions here.


  2. 9

    At this point we might believe that Rust just analyses the whole program and check the validity of all borrows when in assembles the program. But whole program analysis is costly and hard to communicate well (“hey, this borrow doesn’t work because something at the edge of nowhere”).

    And it’s not what happens.

    This was a real moment of clarity for me. I think I ultimately knew that my mental model of lifetimes (which was exactly what you wrote I “might believe” :P) was at least incomplete, since I haven’t understood exactly what the 'lifetime tags are doing. Having that explicitly shut down as wrong feels really freeing to actually understand how else the compiler is working it out!

    And I feel like I’ve now got a great start on that. Nice examples, clearly written and explained. Thanks for the great post!

    1. 2

      A common problem I see in trainings or the Hack & Learn is that presented with a lifetime problem, people start messing around with lifetime syntax.

      This could have been me, I often tried the exact same thing that you pointed out. Thank you for writing this article!