Skip to content

Commit e7299e8

Browse files
Rollup merge of rust-lang#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
2 parents 4931e09 + fcf2426 commit e7299e8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • library/alloc/src/collections/binary_heap

library/alloc/src/collections/binary_heap/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for BinaryHeap<T, A> {
466466
}
467467

468468
#[stable(feature = "rust1", since = "1.0.0")]
469-
impl<T: Ord> Default for BinaryHeap<T> {
469+
impl<T> Default for BinaryHeap<T> {
470470
/// Creates an empty `BinaryHeap<T>`.
471471
#[inline]
472472
fn default() -> BinaryHeap<T> {
@@ -496,7 +496,7 @@ impl<T: Ord, A: Allocator> Drop for RebuildOnDrop<'_, T, A> {
496496
}
497497
}
498498

499-
impl<T: Ord> BinaryHeap<T> {
499+
impl<T> BinaryHeap<T> {
500500
/// Creates an empty `BinaryHeap` as a max-heap.
501501
///
502502
/// # Examples
@@ -537,7 +537,7 @@ impl<T: Ord> BinaryHeap<T> {
537537
}
538538
}
539539

540-
impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
540+
impl<T, A: Allocator> BinaryHeap<T, A> {
541541
/// Creates an empty `BinaryHeap` as a max-heap, using `A` as allocator.
542542
///
543543
/// # Examples
@@ -581,7 +581,9 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
581581
pub fn with_capacity_in(capacity: usize, alloc: A) -> BinaryHeap<T, A> {
582582
BinaryHeap { data: Vec::with_capacity_in(capacity, alloc) }
583583
}
584+
}
584585

586+
impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
585587
/// Returns a mutable reference to the greatest item in the binary heap, or
586588
/// `None` if it is empty.
587589
///

0 commit comments

Comments
 (0)