-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 std::collections
types are unnecessarily invariant
#30642
Comments
I expect the BTreeMap ones will be fixed by #30426 Drain is an interesting case because it's semantically an &mut Collection, but it doesn't enable T's to be written to, only read out. Fixing LinkedList may be as simple as using Shared for RawLink. |
It appears that the remaining |
Make HashMap, HashSet, and their iterators properly covariant See #30642. `Drain` is the only type left invariant.
|
Triage: with the last comment, only two still are. |
The following
std::collections
types are unnecessarily invariant in their type parameters:binary_heap::Drain
btree_map::{Keys, Values}
btree_set::{IntoIter, Iter, Range}
btree_set::{Difference, Intersection, SymmetricDifference, Union}
hash_map::{IntoIter, Iter, Keys, Values}
hash_map::Drain
hash_set::{Difference, Intersection, IntoIter, Iter, SymmetricDifference, Union}
hash_set::Drain
linked_list::{IntoIter, Iter, LinkedList}
vec::Drain
vec_deque::Drain
Some, like
btree_map::Keys
, are invariant due to the use ofiter::Map
withfn(T) -> U
being 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 instd
have the same problem.The text was updated successfully, but these errors were encountered: