David Walker
David Walker
The example was listed in the book itself: ```rust fn longest y.len() { x } else { y } } ``` Obviously the lifetime annotations work correctly in practice. But...
I feel like we're talking past each other here. I can't construct that scenario for you in code, because such a scenario can't exist. That's because there's nothing wrong with...
If you're still hung up on the "only until program start" bit, here's another way of looking at it: `'a` could also have a lifetime that ends immediately before the...
> > `'a` could also have a lifetime that ends immediately before the function is called. That would **also** be logically consistent with the explanation, and is also nonsense in...
I agree, let's try a different direction. What does this sentence (from the book) mean, to you? > The function signature also tells Rust that the string slice returned from...
> I have an example of diagnostics that mention the value of lifetime parameters, [here](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e18373d82cab667d71835488b79f4cf0): > > ``` > fn longest(x: &'a str, y: &'b str) -> &'a str {...
Actually, I know lifetimes **can't** work the same as generics, because of this example: ```rust fn longest y.len() { x } else { y } } ``` If `'a` were...
Yes! I feel like we're finally getting through to each other. Especially now that we're on the same page that generics and lifetimes don't work the same. > There have...
> Here are the lifetimes annotated in the example you provided: > > ``` > fn main() { > let x: String = String::from("foo"); // Lifetime of x starts here...
> > How did you determine that 'a started and ended at those particular lines? That is the information that I think is currently missing from the book. > >...