Exerpad
🔥 0
0 XP
Exercise 8 · Chapter: TraitsRequired+50 XP

Clone and Compare

Create a Score struct with a value: i32 field. Derive Debug, Clone, and PartialEq. Clone a score, modify the clone, then compare them.

Expected output:

Original: Score { value: 100 }
Modified: Score { value: 200 }
Equal: false

Hints:

  • Use #[derive(Debug, Clone, PartialEq)]
  • Clone with let mut copy = original.clone();
  • Modify with copy.value = 200;
rust
fn main() {
}
Output
Run your code to see the output here.