Skip to content

Better Debug implementations for HashMap and BTreeMap Keys/Values iterator structs #75297

Closed
@canova

Description

@canova

For HashMap, we have ValuesMut struct as the return type of HashMap::values_mut method. Although, it return an iterator over values of the map, its Debug implementation prints both keys and values because of the implementation detail. We should only print values for this struct.

For BTreeMap, we also have ValuesMut struct for BTreeMap::values_mut method. We directly derive Debug for it. Which also means that Debug prints both keys and values. We should manually implement Debug instead and print only the values.
In addition to that, for BTreeMap, we also need to change IntoKeys and IntoValues structs. This is not an issue on HashMap because it was correctly implemented in the first place. But it wasn't for BTreeMap because we need an IntoIter::iter method for this first. So we should implement this and fix this issue for them as well.

This was discovered during #75163 and will be the follow-up of it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions