cannot return reference to local variable even with lifetimes
Rust 1.78, edition 2021. A function parses a &str and wants to return a &Vec<Thing> built inside it. Compiler gives error[E0515]: cannot return reference to local variable things. I added explicit lifetimes to input and output and that didn't help, which surprised me. I understand the value is dropped at end of function, I just don't see how to hand back something the caller owns. Is the answer to return the Vec by value here?
3 replies