about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-08-14 04:18:44 +0200
committerGitHub <noreply@github.com>2019-08-14 04:18:44 +0200
commit4e1b86595590e2f78f8b4820a7f51687b31d38df (patch)
tree48813ced0335f3a75e6bf4578f5772b9393f4161 /src
parent6092519e44a09cbac73fb6aa263879f9890b7b8a (diff)
parente30480ca864c5810c89bbf1f475eb0bc2999c251 (diff)
downloadrust-4e1b86595590e2f78f8b4820a7f51687b31d38df.tar.gz
rust-4e1b86595590e2f78f8b4820a7f51687b31d38df.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/liballoc/collections/binary_heap.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs
index 9f531f5b83c..3d04f30e7bd 100644
--- a/src/liballoc/collections/binary_heap.rs
+++ b/src/liballoc/collections/binary_heap.rs
@@ -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();