Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Fix the Bounds

This function needs to both compare and print values, but it's missing one of the trait bounds! Add it.

Fix the code so it prints:

text
Winner: banana

Hint: You need both PartialOrd and std::fmt::Display. Use + to combine them.

rust
fn show_winner<T: PartialOrd>(a: T, b: T) {
if a >= b {
println!("Winner: {}", a);
} else {
println!("Winner: {}", b);
}
}

fn main() {
show_winner("apple", "banana");
}