Skip to content

Commit

Permalink
provide a SpecExtend trait for Vec<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutron3529 committed Nov 12, 2021
1 parent b307481 commit 2feee36
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions library/alloc/src/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2feee36

Please sign in to comment.