When I try to run code below:
let stdin = std::io::stdin();
let lines: Vec<_> = stdin.lock().lines().map(|s| s.unwrap().split(' ')).collect();
I get this error:
error[E0515]: cannot return value referencing temporary value
--> src/main.rs:75:54
|
75 | let lines: Vec<_> = stdin.lock().lines().map(|s| s.unwrap().split(' ')).collect();
| ----------^^^^^^^^^^^
| |
| returns a value referencing data owned by the current function
| temporary value created here
I try do fix this problem in many ways. But I don't know what couse this problem. Can you give me advice how I can resolve this problem. ?