I'm pretty confused by the errors from this simple code (Playground):
fn main() {
let a = fn1("test123");
}
fn fn1(a1: &str) -> &str {
let a = fn2();
a
}
fn fn2() -> &str {
"12345abc"
}
These are:
error[E0106]: missing lifetime specifier
--> <anon>:10:13
|
10 | fn fn2() -> &str {
| ^ expected lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
= help: consider giving it a 'static lifetime
I haven't been faced with these errors before, has anything changed in a recent Rust version? How can I fix the errors?
See Question&Answers more detail:os