Open
Description
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 of iter::Map
with fn(T) -> U
being invariant over T
, while others, like LinkedList
, 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 with iter::Map
, it is likely that some other iterators in std
have the same problem.