Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRustgeneric bounds and whereSingle-choice MCQ

What is wrong with this generic function, and what fixes it?

fn largest<T: PartialOrd>(list: &[T]) -> T { let mut largest = list[0]; for &item in list { if item > largest { largest = item; } } largest }