-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some improvements in collections #14279
Conversation
Thanks for doing this. While you're doing modifying #[deprecated="renamed to `into_vec`"]
fn to_vec(self) -> Vec<T> { self.into_vec() }
#[deprecated="renamed to `into_sorted_vec`"]
fn to_sorted_vec(self) -> Vec<T> { self.into_sorted_vec() }
fn into_vec(self) { /* current code in `.to_vec` */ }
fn into_sorted_vec(self) { /* current code in `.to_sorted_vec` */ } Also, the |
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> PriorityQueue<T> { | ||
let mut q = PriorityQueue::new(); | ||
let (lower, _) = iter.size_hint(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't actually necessary: it is essentially free (no allocation) to create an empty priority queue, and .extend
(below) reserves space itself.
I will add that. Also, I think we should get rid of |
Yep, sounds good. |
I think it is ready! I have done what you said and also added TotalOrd to DList::insert_ordered @huonw r? |
The commits that deprecate or change signatures need to have the Or, alternatively, it's OK if you edited the PR description to include a summary of all the changes, and put the |
@huonw Done! |
The breaking changes are: * Changed `DList::insert_ordered` to use `TotalOrd`, not `Ord` * Changed `PriorityQueue` to use `TotalOrd`, not `Ord` * Deprecated `PriorityQueue::maybe_top()` (renamed to replace `PriorityQueue::top()`) * Deprecated `PriorityQueue::maybe_pop()` (renamed to replace `PriorityQueue::pop()`) * Deprecated `PriorityQueue::to_vec()` (renamed to `PriorityQueue::into_vec()`) * Deprecated `PriorityQueue::to_sorted_vec()` (renamed to `PriorityQueue::into_sorted_vec()`) * Changed `PriorityQueue::replace(...)` to return an `Option<T>` instead of failing when the queue is empty. [breaking-change]
…albasi fix: ignore impls with `#[rustc_reservation_impl]` Fixes rust-lang#12247 Fixes rust-lang#14279 Currently core has two blanket impls for `From`: `impl<T> From<T> for T` and `impl<T> From<!> for T`. These are conflicting and thus chalk cannot uniquely solve `S: From<?0>` for any type `S`. The latter impl is actually a reservation impl and should not be considered during trait selection. More generally, impls attributed with perma-unstable `#[rustc_reservation_impl]` attribute should be disregarded except for coherence checks. See rust-lang#64631 and rust-lang#64715 for details. I chose to entirely ignore them in hir-ty because we don't do coherence checks.
The breaking changes are:
DList::insert_ordered
to useTotalOrd
, notOrd
PriorityQueue
to useTotalOrd
, notOrd
PriorityQueue::maybe_top()
(renamed to replacePriorityQueue::top()
)PriorityQueue::maybe_pop()
(renamed to replacePriorityQueue::pop()
)PriorityQueue::to_vec()
(renamed toPriorityQueue::into_vec()
)PriorityQueue::to_sorted_vec()
(renamed toPriorityQueue::into_sorted_vec()
)PriorityQueue::replace(...)
to return anOption<T>
instead of failing when the queue is empty.[breaking-change]