4 ms·
You summarized it so well ! It was also a huge source of confusion for me in the beginning. Would you mind if I made a pull request to the Rust book adding you
by littlestymaar 9y ago
You summarized it so well ! It was also a huge source of confusion for me in the beginning.
Would you mind if I made a pull request to the Rust book adding your explaination to the lifetime chapter ?
- red75prime 9y agoI wouldn't. Feel free to use it. But I have the impression that the Rust book contains something to that effect. "Descriptive and not prescriptive" part probably comes from stackoverflow. I don't remember exactly.
- steveklabnik 9y agoI'm not sure where I heard it, but I certainly repeat it. It's not literally in the book though, I'll also reply to your parent about this.
- steveklabnik 9y agoWhile it doesn't have this literal text, it already does have the equivalent: https://doc.rust-lang.org/book/second-edition/ch10-03-lifetime-syntax.html#lifetime-annotation-syntax https://doc.rust-lang.org/book/second-edition/ch10-03-lifeti... > Lifetime annotations don’t change how long any of the references involved live. In the same way that functions can accept any type when the signature specifies a generic type parameter, functions can accept references with any lifetime when the signature specifies a generic lifetime parameter. What lifetime annotations do is relate the lifetimes of multiple references to each other.
- littlestymaar 9y agoCool. I haven't read the second version of the book, and I read the first version about two years ago I think. Glad to see this difficulty is now covered. Carry on with the great job Steve :)
- steveklabnik 9y agoAh ha! Yeah, it's quite different. Thanks :)