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

Debug impl for HashMap::keys should not require values to be Debug #41924

Closed
jonhoo opened this Issue May 11, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@jonhoo
Copy link
Contributor

jonhoo commented May 11, 2017

#39002 landed Debug implementations for a number of derived types in collections, but imposes overly strict requirements. For example, for std::collections::hash_map::Keys:

impl<'a, K: Debug, V: Debug> Debug for Keys<'a, K, V> { /* ... */ }

Given that only the keys are printed, we should only require K: Debug, not also V: Debug (unless I'm mistaken?).

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Jun 22, 2017

Yep, seems overly restrictive.

@jonhoo

This comment has been minimized.

Copy link
Contributor Author

jonhoo commented Jun 22, 2017

While we're on it, Values should only require V: Debug, and the same change should be applied to BTreeMap and friends.

bors pushed a commit that referenced this issue Jun 24, 2017

bors added a commit that referenced this issue Jun 24, 2017

Auto merge of #42854 - razielgn:relaxed-debug-constraints-on-maps-ite…
…rators, r=sfackler

Relaxed Debug constraints on {HashMap,BTreeMap}::{Keys,Values}.

I has hit by this yesterday too. 😄
And I've realised that Debug for BTreeMap::{Keys,Values} wasn't formatting just keys and values respectively, but the whole map. 🤔

Fixed #41924

r? @jonhoo

@bors bors closed this in #42854 Jun 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.