Expanding Rust Lifetime
I have a bit of code that I'm fighting with. It's a little helper function that should return a Vec<&str> to the calling function. I can't seem to get the lifetime right, though. Here is the code snippet: fn take_symbol<'a>(ch: &'a str, current: &'a mut String) -> &'a mut TokenList<'a> { let out = TokenList::<'a>::new(); out.push(current.as_str()); out.push(ch); *current = String::new(); &mut out } The compiler is telling me: error: 'out' does not live long enough and that the reference must be valid for the lifetime of 'a , but it looks to me like it is defined for 'a . I have also tried