Can the lifetimes be simpler?

As a counter-example, see how cryptic and confusing implicit lifetimes of closures can be.

Without explicit type annotations, the correct lifetimes can only be picked by type inference, and Rust becomes super annoying when you get wrong lifetime defaults in closures and type inference doesn't guess what you mean:

4 Likes

Thanks! I understand what you mean. The lifetimes is indeed a very good design, which helps people design projects with better stability.

The conventions set by function signatures are very important for callers

Thanks sincerely for all your reply, which gave me a more comprehensive understanding of Rust's lifetimes! This is a great design, instead of a compromise.

I hope to use this question to inspire thinking about how to make the lifetime design better. Seems like I underestimated its complexity :slight_smile:

2 Likes

Yes, and I think this topic has been brought up for quite a few times as well. I have always wanted to wrap up a PoC implementation but never had the time... (and not sure how to handle recursion.)