Borrowed value does not live long enough when creating a Vec
问题 Editor's note: This question was asked before Rust 1.0. Since then, many functions and types have changed, as have certain language semantics. The code in the question is no longer valid, but the ideas expressed in the answers may be. I'm trying to list the files in a directory and copy the filename to my own Vec . I've tried several solutions, but it always ends up with a problem of not being able to create long enough living variables. I don't understand my mistake. fn getList(action_dir