News for hackers. Stuff that matters.
Re:Rust Lifetimes by shadowmint on Saturday October 31, 2015 @06:36PM (#10484498)
cool post. what about traits and 'static?

Anyhow; Its definitely worth making two points about lifetimes very clear:

1) They don't exist at runtime.

Lifetimes are purely a compile time thing the compiler uses for formal safety.

2) 'a is not a actual lifetime, it is the minimum possible life time valid for that item; ie. a bound, not a concrete value.

&'a means; this arg/trait/ref/whatever must live at least as long as 'a. That's why different objects with different lifetimes can coexist in a struct of 'a, without needing 'a, 'b, 'c etc for each reference in the struct.

Re:Rust Lifetimes by dbaupp on Saturday October 31, 2015 @08:14PM (#10484838)
It's not clear from context in your comment if you're saying this, but, for `x: &'a T`, 'a is a bound in two ways:

- it is the maximum possible lifetime of the x variable itself,

- it is the minimum lifetime of the `T` instance x points to.

These are 100% related of course (x can't point to something that is invalid), but it is worth being careful about which end of a reference/pointer you're talking about when talking about validity.

Re:Rust Lifetimes by sixbrx on Sunday November 01, 2015 @07:17AM (#10486197)
Thanks for this comment, that clarifies things a lot for me. I think it should be in the docs (with equal brevity) if not already.
Re:Rust Lifetimes by steveklabnik on Sunday November 01, 2015 @09:06AM (#10486425)
I've made a note to check it out, thanks.