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:
parent
b3074819f6
commit
2feee3659e
1 changed files with 8 additions and 0 deletions
|
@ -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> {
|
impl<T: Ord> SpecExtend<BinaryHeap<T>> for BinaryHeap<T> {
|
||||||
fn spec_extend(&mut self, ref mut other: BinaryHeap<T>) {
|
fn spec_extend(&mut self, ref mut other: BinaryHeap<T>) {
|
||||||
self.append(other);
|
self.append(other);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue