The Power of Lifetimes

The Power of Lifetimes

The purpose of all forms of automatic memory management is to track the lifetimes of all strong references to that object. For the most part, lifetime annotations are only needed to simplify lifetime analysis for these potentially ambiguous situations:

Rust 2018 Edition improves on borrowed reference lifetimes by adding support for “non-lexical lifetimes”. With non-lexical lifetimes, Rust can detect that use of the borrowed reference finishes before the end of the block, enabling it to expire the usage lock earlier and allow subsequent, safe use of the original resource within that block.

Source: pling.jondgoodwin.com