Pre-RFC: BinaryHeap Flexibility

You could actually do it with static dispatch if you keep the type parameter. It just needs a fair bit of boilerplate to create named Fn* implementations (playground). In general, you could use impl Fn(&T, &T) -> Ordering, but it doesn’t work for inherent constructors (like new, new_max, …), since there’s no way to make the type of Self depend on an unnamed closure type.

1 Like