Skip to content

Commit

Permalink
Rollup merge of rust-lang#63486 - Observer42:document-from-trait-in-b…
Browse files Browse the repository at this point in the history
…inaryheap, 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
  • Loading branch information
Centril authored Aug 12, 2019
2 parents b503f8e + e30480c commit 2125c78
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/liballoc/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2125c78

Please sign in to comment.