我对这段简单代码 (Playground) 中的错误感到相当困惑:
fn main() {
let a = fn1("test123");
}
fn fn1(a1: &str) -> &str {
let a = fn2();
a
}
fn fn2() -> &str {
"12345abc"
}
这些内容包括:
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
我以前没有遇到过这些错误,最近的Rust版本有什么改变吗?我该如何修复这些错误?