Skip to content

Commit 472a839

Browse files
committed
make 'into_vec' just using 'self.data'
1 parent 338323b commit 472a839

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/binary_heap.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl private::Sealed for Min {}
100100
101101
pub struct BinaryHeap<T, K, const N: usize> {
102102
pub(crate) _kind: PhantomData<K>,
103-
pub(crate) data: ManuallyDrop<Vec<T, N>>,
103+
pub(crate) data: Vec<T, N>,
104104
}
105105

106106
impl<T, K, const N: usize> BinaryHeap<T, K, N> {
@@ -120,7 +120,7 @@ impl<T, K, const N: usize> BinaryHeap<T, K, N> {
120120
pub const fn new() -> Self {
121121
Self {
122122
_kind: PhantomData,
123-
data: ManuallyDrop::new(Vec::new()),
123+
data: Vec::new(),
124124
}
125125
}
126126
}
@@ -338,10 +338,7 @@ where
338338

339339
/// Returns the underlying ```Vec<T,N>```. Order is arbitrary and time is O(1).
340340
pub fn into_vec(self) -> Vec<T, N> {
341-
// prevents dropping self.data at the end of this fn
342-
let mut dropless_heap = ManuallyDrop::new(self);
343-
// https://users.rust-lang.org/t/moving-out-of-a-type-implementing-drop/38225/5
344-
unsafe { ManuallyDrop::take(&mut dropless_heap.data) }
341+
self.data
345342
}
346343

347344
/* Private API */

0 commit comments

Comments
 (0)