Implement BinaryHeap::pop_if()#151829
Conversation
|
I'm getting errors compiling an I added |
This comment has been minimized.
This comment has been minimized.
| /// The worst case cost of `pop_if` on a heap containing *n* elements is *O*(log(*n*)). | ||
| #[unstable(feature = "binary_heap_pop_if", issue = "151828")] | ||
| pub fn pop_if(&mut self, predicate: impl FnOnce(&T) -> bool) -> Option<T> { | ||
| let first = self.data.first()?; |
There was a problem hiding this comment.
peek is just a bit nicer.
| let first = self.data.first()?; | |
| let first = self.peek()?; |
library/alloctests/lib.rs
Outdated
| #![feature(allocator_api)] | ||
| #![feature(array_into_iter_constructors)] | ||
| #![feature(assert_matches)] | ||
| #![feature(binary_heap_pop_if)] |
There was a problem hiding this comment.
This is the wrong lib.rs, you'll need to add the feature to alloctests/src/lib.rs instead. We use this lib.rs only for running the doctests and internal tests of alloc (I can't remember why alloc can't be tested directly just now, but there was some reason).
There was a problem hiding this comment.
That did it, thanks!
| /// | ||
| /// # Examples | ||
| /// | ||
| /// ``` |
There was a problem hiding this comment.
You'll need to add the feature here too, otherwise the doctest will fail 😉
|
Reminder, once the PR becomes ready for a review, use |
|
Thanks for the review! |
|
@bors r=jhpratt,joboet rollup |
Implementation of #151828