I want create a function that split and return vector.
I'm trying change line type, but its dont help.
Code:
pub fn format(&self, basic_line: String) -> Vec<&str> {
let temp_line = basic_line.trim().to_lowercase();
return temp_line.split_whitespace().collect();
}
Error Output:
error[E0515]: cannot return value referencing temporary value
--> src\module.rs:55:16
|
53 | let f_line:Vec<&str> = line.trim().to_lowercase().split_whitespace().collect();
| -------------------------- temporary value created here
54 |
55 | return f_line;
| ^^^^^^ returns a value referencing data owned by the current function
For more information about this error, try `rustc --explain E0515`