Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Fix the Derive

This code tries to print a struct with {:?} and compare two structs with ==, but it's missing the right derive attributes! Add them.

Fix the code so it prints:

text
Point { x: 1, y: 2 }
Equal: true

Hint: You need #[derive(Debug, PartialEq)] on the struct.

rust
struct Point {
x: i32,
y: i32,
}

fn main() {
let p1 = Point { x: 1, y: 2 };
let p2 = Point { x: 1, y: 2 };
println!("{:?}", p1);
println!("Equal: {}", p1 == p2);
}