diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-04-25 01:35:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-25 01:35:59 +0200 |
| commit | e20ca112cc821136f2bf314c6b61fdb73a2e8d8d (patch) | |
| tree | 7a51803c06f52b42d1306ef848044227f10ba4b8 /src/liballoc/tests | |
| parent | a23d8ec8a7525ae90e7625312cc2bee83dbb7493 (diff) | |
| parent | 787eddc1ab49766204c35d2a60c3d75b6ea7413c (diff) | |
| download | rust-e20ca112cc821136f2bf314c6b61fdb73a2e8d8d.tar.gz rust-e20ca112cc821136f2bf314c6b61fdb73a2e8d8d.zip | |
Rollup merge of #71485 - arlopurcell:binary_heap_retain, r=Amanieu
Add BinaryHeap::retain as suggested in #42849 This PR implements retain for BinaryHeap as suggested in #42849. This is my first PR for Rust, so please let me know if I should be doing anything differently, thanks!
Diffstat (limited to 'src/liballoc/tests')
| -rw-r--r-- | src/liballoc/tests/binary_heap.rs | 8 | ||||
| -rw-r--r-- | src/liballoc/tests/lib.rs | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/liballoc/tests/binary_heap.rs b/src/liballoc/tests/binary_heap.rs index 057afd41824..62084ccf53c 100644 --- a/src/liballoc/tests/binary_heap.rs +++ b/src/liballoc/tests/binary_heap.rs @@ -372,6 +372,14 @@ fn assert_covariance() { } } +#[test] +fn test_retain() { + let mut a = BinaryHeap::from(vec![-10, -5, 1, 2, 4, 13]); + a.retain(|x| x % 2 == 0); + + assert_eq!(a.into_sorted_vec(), [-10, 2, 4]) +} + // old binaryheap failed this test // // Integrity means that all elements are present after a comparison panics, diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs index ad6feaeebc6..78d49558262 100644 --- a/src/liballoc/tests/lib.rs +++ b/src/liballoc/tests/lib.rs @@ -14,6 +14,7 @@ #![feature(binary_heap_drain_sorted)] #![feature(vec_remove_item)] #![feature(split_inclusive)] +#![feature(binary_heap_retain)] use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; |
