error bound-not-satisfied
What it means#
A type argument does not satisfy a bound of the generic parameter: an interface (T: Ord) or a where predicate (§4.8). The argument may be given explicitly or inferred from the call.
Example#
fn max<T>(a: T, b: T) -> T where T: Ord => if a > b { a } else { b }
data P { x: i32 }
fn main() {
let m = max(P{ x: 1 }, P{ x: 2 }) // <- bound-not-satisfied (P is not Ord)
}error
bound-not-satisfied
How to fix#
fn max<T>(a: T, b: T) -> T where T: Ord => if a > b { a } else { b }
@derive(Eq, Ord)
data P { x: i32 }
fn main() {
let m = max(P{ x: 1 }, P{ x: 2 })
}Make the type satisfy the bound (implement the interface or @derive it), or pass a different type.