Answers for "rust•armanazi•error•[E0106]: missing lifetime specifier --> src/main.rs:5:16 | 5 | fn dangle() -> &String { | ^ expected named lifetime parameter"

0

rust•armanazi•error•[E0106]: missing lifetime specifier --> src/main.rs:5:16 | 5 | fn dangle() -> &String { | ^ expected named lifetime parameter

fn no_dangle() -> String {
    let s = String::from("hello");

    s
}
This works without any problems. Ownership is moved out, and nothing is deallocated.
Posted by: Guest on March-19-2022

Code answers related to "rust•armanazi•error•[E0106]: missing lifetime specifier --> src/main.rs:5:16 | 5 | fn dangle() -> &String { | ^ expected named lifetime parameter"

Browse Popular Code Answers by Language