]> git.lizzy.rs Git - rust.git/commit
collections: Make BinaryHeap panic safe in sift_up / sift_down
authorUlrik Sverdrup <root@localhost>
Thu, 28 May 2015 08:44:31 +0000 (10:44 +0200)
committerUlrik Sverdrup <root@localhost>
Thu, 28 May 2015 18:24:47 +0000 (20:24 +0200)
commit5249cbb7fa31ea2e6e8d77b49bfda386215b1ce7
tree4c6141bb8b5b9c7baf8018e1a5d10001ae134212
parent541fe5faf876121df036f089d594fd30e01b0403
collections: Make BinaryHeap panic safe in sift_up / sift_down

Use a struct called Hole that keeps track of an invalid location
in the vector and fills the hole on drop.

I include a run-pass test that the current BinaryHeap fails, and the new
one passes.

Fixes #25842
src/libcollections/binary_heap.rs
src/test/run-pass/binary-heap-panic-safe.rs [new file with mode: 0644]