Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Fix the Move

Oh no! This code tries to use a String after it was moved. Fix it so the program compiles and prints:

text
Hello, Luna!
Name is: Luna

Hint: Use borrowing (&) so the function doesn't take ownership!

rust
fn greet(name: String) {
println!("Hello, {}!", name);
}

fn main() {
let name = String::from("Luna");
greet(name);
println!("Name is: {}", name);
}