Code
fn values() -> &[i32] {
let values = vec![1, 2];
&values
}
Current output
error[E0106]: missing lifetime specifier
--> src/lib.rs:1:16
|
1 | fn values() -> &[i32] {
| ^ expected named 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 using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
1 | fn values() -> &'static [i32] {
| +++++++
help: instead, you are more likely to want to return an owned value
|
1 - fn values() -> &[i32] {
1 + fn values() -> [i32] {
|
Desired output
error[E0106]: missing lifetime specifier
--> src/lib.rs:1:16
|
1 | fn values() -> &[i32] {
| ^ expected named 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 using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
1 | fn values() -> &'static [i32] {
| +++++++
help: instead, you are more likely to want to return an owned value
|
1 - fn values() -> &[i32] {
1 + fn values() -> Vec<i32> {
|
Rationale and extra context
No response
Other cases
Rust Version
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
No response
Other cases
Rust Version
Anything else?
No response