This is a nice reference for what to do when you are returning one reference from a function to appease the borrow checker: https://bryce.fisher-fleig.org/strategies-for-returning-references-in-rust/
However, I would like to find a generic solution for creating a bunch of objects say within a loop so you can't know at compile time how many there will be. I then want to link them together by reference and return them.
For example, I create a bunch of linked list nodes, link them together then want to return the head. I'm guessing boxing is the only solution that really works?