about summary refs log tree commit diff
path: root/src/liballoc/tests/lib.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-10-31 15:15:53 +0000
committerbors <bors@rust-lang.org>2019-10-31 15:15:53 +0000
commitaa4e57ca8f18b836bf77923cd0d9ad1390f0110b (patch)
treeed4e7119840dea12d6ec237a7e018edfc5d8c63b /src/liballoc/tests/lib.rs
parent92df638162b7ccea6f97a8e1287ed05c5c0818b4 (diff)
parent95442ae251d24c062ca317dcafdf3240f3cec846 (diff)
downloadrust-aa4e57ca8f18b836bf77923cd0d9ad1390f0110b.tar.gz
rust-aa4e57ca8f18b836bf77923cd0d9ad1390f0110b.zip
Auto merge of #65091 - sekineh:into-iter-sorted, r=KodrAus
Implement ordered/sorted iterators on BinaryHeap as per #59278

I've implemented the ordered version of iterator on BinaryHeap as per #59278.

# Added methods:

* `.into_iter_sorted()`
  * like `.into_iter()`; but returns elements in heap order
* `.drain_sorted()`
  * like `.drain()`; but returns elements in heap order
  * It's a bit _lazy_; elements are removed on drop. (Edit: it’s similar to vec::Drain)

For `DrainSorted` struct, I implemented `Drop` trait following @scottmcm 's [suggestion](https://github.com/rust-lang/rust/issues/59278#issuecomment-537306925)

# ~TODO~ DONE
* ~I think I need to add more tests other than doctest.~

# **Notes:**
* we renamed `_ordered` to `_sorted`, because the latter is more common in rust libs. (as suggested by @KodrAus )
Diffstat (limited to 'src/liballoc/tests/lib.rs')
-rw-r--r--src/liballoc/tests/lib.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs
index 79e5ba340b7..3273feb7b5d 100644
--- a/src/liballoc/tests/lib.rs
+++ b/src/liballoc/tests/lib.rs
@@ -8,6 +8,8 @@
 #![feature(try_reserve)]
 #![feature(unboxed_closures)]
 #![feature(associated_type_bounds)]
+#![feature(binary_heap_into_iter_sorted)]
+#![feature(binary_heap_drain_sorted)]
 
 use std::hash::{Hash, Hasher};
 use std::collections::hash_map::DefaultHasher;