Lifetimes enable us to use references as first class types. This means they can occur in nested positions: You can now have a reference to a reference, you can have an array of references, etc. At the machine/execution level, a reference is identical to a pointer, but the reference type system enables an associated lifetime, tracking of mutability etc.
Writing a lifetime bound reference
The first question is how to spell this. Rust uses the syntax which is pretty unconventional and (weirdly but) distinctly Rust. For example, here are some simple Rust functions:'a
// This is Rust
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {..}
fn longest2<'a>(x: &'a mut str, y: &'a mut str) -> &'a mut str {..}
原文:https://github.com/modularml/mojo/blob/main/proposals/lifetimes-and-provenance.md