Add BinaryHeap::retain as suggested in #42849
This commit is contained in:
parent
00f677d897
commit
787eddc1ab
3 changed files with 37 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue