Skip to content

Commit 2feee36

Browse files
committed
provide a SpecExtend trait for Vec<T>
The discussion is [here](https://internals.rust-lang.org/t/append-vec-to-binaryheap/15209/3)
1 parent b307481 commit 2feee36

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/alloc/src/collections/binary_heap.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,14 @@ impl<T: Ord, I: IntoIterator<Item = T>> SpecExtend<I> for BinaryHeap<T> {
15841584
}
15851585
}
15861586

1587+
impl<T: Ord> SpecExtend<Vec<T>> for BinaryHeap<T> {
1588+
fn spec_extend(&mut self, ref mut other: Vec<T>) {
1589+
let start = self.data.len();
1590+
self.data.append(other);
1591+
self.rebuild_tail(start);
1592+
}
1593+
}
1594+
15871595
impl<T: Ord> SpecExtend<BinaryHeap<T>> for BinaryHeap<T> {
15881596
fn spec_extend(&mut self, ref mut other: BinaryHeap<T>) {
15891597
self.append(other);

0 commit comments

Comments
 (0)