Skip to content

Commit 2125c78

Browse files
authored
Rollup merge of rust-lang#63486 - Observer42:document-from-trait-in-binaryheap, r=Centril
Document `From` trait for `BinaryHeap` This PR solves part of rust-lang#51430. (cc @skade) The comments described allocation and time complexity of the conversion from Vec to BinaryHeap The complexity description of BinaryHeap operations is available at mod level: https://doc.rust-lang.org/alloc/collections/binary_heap/index.html But it doesn't show up at BinaryHeap page: https://doc.rust-lang.org/alloc/collections/binary_heap/struct.BinaryHeap.html
2 parents b503f8e + e30480c commit 2125c78

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/liballoc/collections/binary_heap.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,9 @@ impl<T> FusedIterator for Drain<'_, T> {}
11631163

11641164
#[stable(feature = "binary_heap_extras_15", since = "1.5.0")]
11651165
impl<T: Ord> From<Vec<T>> for BinaryHeap<T> {
1166+
/// Converts a `Vec<T>` into a `BinaryHeap<T>`.
1167+
///
1168+
/// This conversion happens in-place, and has `O(n)` time complexity.
11661169
fn from(vec: Vec<T>) -> BinaryHeap<T> {
11671170
let mut heap = BinaryHeap { data: vec };
11681171
heap.rebuild();

0 commit comments

Comments
 (0)