Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Fix the Struct

This code defines a Car struct, but there's a problem when creating the instance — one of the fields is missing!

Fix the code so it prints:

text
Red Toyota, year 2020

Hint: Check the struct definition and make sure every field has a value when creating the instance.

rust
struct Car {
color: String,
brand: String,
year: i32,
}

fn main() {
let car = Car {
color: String::from("Red"),
brand: String::from("Toyota"),
};
println!("{} {}, year {}", car.color, car.brand, car.year);
}