I am trying to convert a String
to an &str
. But the problem is that rust will always throw this error:
error[E0515]: cannot return value referencing local variable `contents`
--> src/utils.rs:111:5
|
72 | let contents = &contents[..];
| -------- `contents` is borrowed here
...
111 | result
| ^^^^^^ returns a value referencing data owned by the current function
For more information about this error, try `rustc --explain E0515`.
How do i convert the variable into an &str?