Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Fix the Concat

This code tries to combine two strings with +, but it has an ownership problem! The + operator takes ownership of the first string, so you need to make sure the types are right.

Fix the code so it prints:

text
Hello World

Hint: The + operator needs a String on the left and a &str on the right. Try using format!() instead — it's easier and doesn't take ownership!

rust
fn main() {
let a = "Hello";
let b = "World";
let result = a + " " + b;
println!("{}", result);
}