Hacker News new | past | comments | ask | show | jobs | submit login

There are 4 places where you use lifetimes. It's really not hard syntax-wise.

I teach Rust workshops and I find that novice users struggle with this, because they think of references as pointers, so they use them in places where they don't make sense (e.g. in owned structs or returned from constructors), and then desperately try every possible lifetime syntax to force through an impossible borrow.

In practice, once you "get" ownership, it's rare to use any lifetime syntax at all! In a codebase I have open right now (which is in production in 194 datecenters) only 3% of uses of references have a lifetime annotation, and it's just `<'a>` and `&'a`, nothing more complex.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: