about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNeutron3529 <qweytr_1@163.com>2021-08-24 14:41:28 +0800
committerNeutron3529 <qweytr_1@163.com>2021-11-12 15:45:25 +0800
commit2feee3659e19fddf2eb47ea37293cae73bd52c98 (patch)
tree321cab39a04cb877409e7f22425f06cc584d582f
parentb3074819f615758da44a667bf3cb98c59227e2f9 (diff)
downloadrust-2feee3659e19fddf2eb47ea37293cae73bd52c98.tar.gz
rust-2feee3659e19fddf2eb47ea37293cae73bd52c98.zip
provide a `SpecExtend` trait for `Vec<T>`
The discussion is [here](https://internals.rust-lang.org/t/append-vec-to-binaryheap/15209/3)
-rw-r--r--library/alloc/src/collections/binary_heap.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs
index 7fb7686a6e2..7d87974b47e 100644
--- a/library/alloc/src/collections/binary_heap.rs
+++ b/library/alloc/src/collections/binary_heap.rs
@@ -1584,6 +1584,14 @@ impl<T: Ord, I: IntoIterator<Item = T>> SpecExtend<I> for BinaryHeap<T> {
     }
 }
 
+impl<T: Ord> SpecExtend<Vec<T>> for BinaryHeap<T> {
+    fn spec_extend(&mut self, ref mut other: Vec<T>) {
+        let start = self.data.len();
+        self.data.append(other);
+        self.rebuild_tail(start);
+    }
+}
+
 impl<T: Ord> SpecExtend<BinaryHeap<T>> for BinaryHeap<T> {
     fn spec_extend(&mut self, ref mut other: BinaryHeap<T>) {
         self.append(other);