summaryrefslogtreecommitdiff
path: root/src/binary_heap.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/binary_heap.rs45
1 files changed, 39 insertions, 6 deletions
diff --git a/src/binary_heap.rs b/src/binary_heap.rs
index dc9ea590..5bf01827 100644
--- a/src/binary_heap.rs
+++ b/src/binary_heap.rs
@@ -537,12 +537,6 @@ where
}
}
-impl<T, K, const N: usize> Drop for BinaryHeap<T, K, N> {
- fn drop(&mut self) {
- unsafe { ptr::drop_in_place(self.data.as_mut_slice()) }
- }
-}
-
impl<T, K, const N: usize> fmt::Debug for BinaryHeap<T, K, N>
where
K: Kind,
@@ -578,6 +572,45 @@ mod tests {
}
#[test]
+ fn drop() {
+ droppable!();
+
+ {
+ let mut v: BinaryHeap<Droppable, Max, 2> = BinaryHeap::new();
+ v.push(Droppable::new()).ok().unwrap();
+ v.push(Droppable::new()).ok().unwrap();
+ v.pop().unwrap();
+ }
+
+ assert_eq!(unsafe { COUNT }, 0);
+
+ {
+ let mut v: BinaryHeap<Droppable, Max, 2> = BinaryHeap::new();
+ v.push(Droppable::new()).ok().unwrap();
+ v.push(Droppable::new()).ok().unwrap();
+ }
+
+ assert_eq!(unsafe { COUNT }, 0);
+
+ {
+ let mut v: BinaryHeap<Droppable, Min, 2> = BinaryHeap::new();
+ v.push(Droppable::new()).ok().unwrap();
+ v.push(Droppable::new()).ok().unwrap();
+ v.pop().unwrap();
+ }
+
+ assert_eq!(unsafe { COUNT }, 0);
+
+ {
+ let mut v: BinaryHeap<Droppable, Min, 2> = BinaryHeap::new();
+ v.push(Droppable::new()).ok().unwrap();
+ v.push(Droppable::new()).ok().unwrap();
+ }
+
+ assert_eq!(unsafe { COUNT }, 0);
+ }
+
+ #[test]
fn min() {
let mut heap = BinaryHeap::<_, Min, 16>::new();
heap.push(1).unwrap();