Rollup merge of #63486 - Observer42:document-from-trait-in-binaryheap, r=Centril

Document `From` trait for `BinaryHeap`

This PR solves part of #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
This commit is contained in:
Mazdak Farrokhzad 2019-08-14 04:18:44 +02:00 committed by GitHub
commit 4e1b865955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1163,6 +1163,9 @@ impl<T> FusedIterator for Drain<'_, T> {}
#[stable(feature = "binary_heap_extras_15", since = "1.5.0")]
impl<T: Ord> From<Vec<T>> for BinaryHeap<T> {
/// Converts a `Vec<T>` into a `BinaryHeap<T>`.
///
/// This conversion happens in-place, and has `O(n)` time complexity.
fn from(vec: Vec<T>) -> BinaryHeap<T> {
let mut heap = BinaryHeap { data: vec };
heap.rebuild();