A shape (like Show, Ord or your own) asks for certain functions. This type lacks one, so it
can't be used where the shape is needed. The note names the missing function.
Wrong#
struct P { x: int }
fn main() { print([P { x: 2 }, P { x: 1 }].sort()) }Fixed#
struct P { x: int }
fn cmp(a: P, b: P): int = a.x - b.x
fn main() { print([P { x: 2 }, P { x: 1 }].sort()) }Common causes#
- Sorting or comparing structs: define
cmp(Ordisn't automatic). - A generic
Tinterpolated into a string: bound it,fn f<T: Show>(x: T). - Printing a closure: closures don't fit
Show.