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

> To use the example from the article: lifetimes are not a hard concept to grasp. Knowing when the Rust compiler will require you to make a lifetime explicitly part of your type, vs. when you can elide it? Hard.

There are only three (or is it four?) rules about when you can elide. Personally? I never write lifetimes, and then the compiler yells at me, and then I fix it by adding them. It's not something that you need to actively think about. You see

    error[E0106]: missing lifetime specifier
     --> src/lib.rs:2:8
      |
    2 |     x: &i32,
      |        ^ expected lifetime parameter
and you add it in.



Lifetimes trip me up in Javascript all the time. I think that I have all my callbacks and/or promises lined up and dealt and my app runs fine. Until it doesn't and I discover that there is some corner case in my 5 nested deep callback hell where I didn't catch some DB timeout. I'm looking forward to that never happening again in Rust.




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

Search: