Because when you put a temporary borrow inside a struct, the struct as a whole becomes temporary. If it didn't, it could end up referencing something after it's gone (that's a dangling pointer, and it's a security vulnerability). So there has to be a guarantee that the struct will be destroyed before everything that it references is destroyed.
Rust doesn't have a garbage collector, so it can't make struct content live longer if necessary. It can only force struct to live shorter instead.
While the compiler technically doesn't have to require an explicit syntax lifetime in all cases, it absolutely has to track struct's lifetime in all cases. The "infectious" nature of Rust's temporary borrows is necessary for safety. The syntax becomes necessary in some more complicated cases and in generic code where there isn't specific code to analyze.
But the syntax exists and it's deliberately tedious and annoying to remind you that temporary borrows in structs are not easy to use, and shouldn't be used lightly. They come with lots of hard limitations, and you're going to be reminded about that every time you write <'a>
.
You don't write these <'a>
in other languages, because references in other languages are equivalent to what Rust calls Arc<Mutex<T>>
(if they're safe) or *mut T
(if they're unsafe). In Rust you also don't need to write lifetime annotations for these other kinds of references. Only scope-limited temporary references need to annotate the scope they're bound to.