Skip to content

Commit

Permalink
Rollup merge of rust-lang#117316 - Coekjan:const-binary-heap-construc…
Browse files Browse the repository at this point in the history
…tor, r=dtolnay

Mark constructor of `BinaryHeap` as const fn

rust-lang#112353
  • Loading branch information
workingjubilee authored Oct 29, 2023
2 parents 10c9c7c + 4dd7568 commit 2dd37d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions library/alloc/src/collections/binary_heap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ impl<T: Ord> BinaryHeap<T> {
/// heap.push(4);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
#[must_use]
pub fn new() -> BinaryHeap<T> {
pub const fn new() -> BinaryHeap<T> {
BinaryHeap { data: vec![] }
}

Expand Down Expand Up @@ -477,8 +478,9 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
/// heap.push(4);
/// ```
#[unstable(feature = "allocator_api", issue = "32838")]
#[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
#[must_use]
pub fn new_in(alloc: A) -> BinaryHeap<T, A> {
pub const fn new_in(alloc: A) -> BinaryHeap<T, A> {
BinaryHeap { data: Vec::new_in(alloc) }
}

Expand Down

0 comments on commit 2dd37d4

Please sign in to comment.