provide a SpecExtend trait for Vec<T>

The discussion is [here](https://internals.rust-lang.org/t/append-vec-to-binaryheap/15209/3)
This commit is contained in:
Neutron3529 2021-08-24 14:41:28 +08:00
parent b3074819f6
commit 2feee3659e

View File

@ -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);