Rollup merge of #117316 - Coekjan:const-binary-heap-constructor, r=dtolnay

Mark constructor of `BinaryHeap` as const fn

#112353
This commit is contained in:
Jubilee 2023-10-28 17:08:05 -07:00 committed by GitHub
commit 2dd37d402c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -434,8 +434,9 @@ impl<T: Ord> BinaryHeap<T> {
/// heap.push(4); /// heap.push(4);
/// ``` /// ```
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
#[must_use] #[must_use]
pub fn new() -> BinaryHeap<T> { pub const fn new() -> BinaryHeap<T> {
BinaryHeap { data: vec![] } BinaryHeap { data: vec![] }
} }
@ -477,8 +478,9 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
/// heap.push(4); /// heap.push(4);
/// ``` /// ```
#[unstable(feature = "allocator_api", issue = "32838")] #[unstable(feature = "allocator_api", issue = "32838")]
#[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
#[must_use] #[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) } BinaryHeap { data: Vec::new_in(alloc) }
} }