Rollup merge of #149408 - aatifsyed/binary-heap-no-ord, r=tgross35,dtolnay

refactor: remove Ord bound from BinaryHeap::new etc

This adds consistency with e.g `BTreeMap::new`, and makes it easier to e.g `#[derive(Default)]`[^1]

[^1]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=f848e472a176fae155f17455bdfe0aee
This commit is contained in:
Jonathan Brouwer 2026-01-14 11:05:36 +01:00 committed by GitHub
commit 91429523f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -466,7 +466,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for BinaryHeap<T, A> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Default for BinaryHeap<T> {
impl<T> Default for BinaryHeap<T> {
/// Creates an empty `BinaryHeap<T>`.
#[inline]
fn default() -> BinaryHeap<T> {
@ -496,7 +496,7 @@ impl<T: Ord, A: Allocator> Drop for RebuildOnDrop<'_, T, A> {
}
}
impl<T: Ord> BinaryHeap<T> {
impl<T> BinaryHeap<T> {
/// Creates an empty `BinaryHeap` as a max-heap.
///
/// # Examples
@ -537,7 +537,7 @@ impl<T: Ord> BinaryHeap<T> {
}
}
impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
impl<T, A: Allocator> BinaryHeap<T, A> {
/// Creates an empty `BinaryHeap` as a max-heap, using `A` as allocator.
///
/// # Examples
@ -581,7 +581,9 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
pub fn with_capacity_in(capacity: usize, alloc: A) -> BinaryHeap<T, A> {
BinaryHeap { data: Vec::with_capacity_in(capacity, alloc) }
}
}
impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
/// Returns a mutable reference to the greatest item in the binary heap, or
/// `None` if it is empty.
///