-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Some std::collections types are unnecessarily invariant #30642
Copy link
Copy link
Open
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The following
std::collectionstypes are unnecessarily invariant in their type parameters:binary_heap::Drainbtree_map::{Keys, Values}btree_set::{IntoIter, Iter, Range}btree_set::{Difference, Intersection, SymmetricDifference, Union}hash_map::{IntoIter, Iter, Keys, Values}hash_map::Drainhash_set::{Difference, Intersection, IntoIter, Iter, SymmetricDifference, Union}hash_set::Drainlinked_list::{IntoIter, Iter, LinkedList}vec::Drainvec_deque::DrainSome, like
btree_map::Keys, are invariant due to the use ofiter::Mapwithfn(T) -> Ubeing invariant overT, while others, likeLinkedList, are due to the ultimate use of*mut T, and the rest are wrappers around other invariant iterators.Of these, the most important to fix is probably
LinkedList, as the rest are iterators. Given the issue withiter::Map, it is likely that some other iterators instdhave the same problem.