From 2feee3659e19fddf2eb47ea37293cae73bd52c98 Mon Sep 17 00:00:00 2001 From: Neutron3529 Date: Tue, 24 Aug 2021 14:41:28 +0800 Subject: [PATCH] provide a `SpecExtend` trait for `Vec` The discussion is [here](https://internals.rust-lang.org/t/append-vec-to-binaryheap/15209/3) --- library/alloc/src/collections/binary_heap.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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> SpecExtend for BinaryHeap { } } +impl SpecExtend> for BinaryHeap { + fn spec_extend(&mut self, ref mut other: Vec) { + let start = self.data.len(); + self.data.append(other); + self.rebuild_tail(start); + } +} + impl SpecExtend> for BinaryHeap { fn spec_extend(&mut self, ref mut other: BinaryHeap) { self.append(other);