Skip to content
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

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

Closed
canova opened this issue Aug 8, 2020 · 1 comment · Fixed by #75377
Closed

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

canova opened this issue Aug 8, 2020 · 1 comment · Fixed by #75377
Assignees

Comments

@canova
Copy link
Contributor

canova commented Aug 8, 2020

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.

@canova
Copy link
Contributor Author

canova commented Aug 8, 2020

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant