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
Closed

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

jonhoo opened this issue May 11, 2017 · 2 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@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?).

@Mark-Simulacrum Mark-Simulacrum added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jun 22, 2017
@sfackler sfackler added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Jun 22, 2017
@sfackler
Copy link
Member

Yep, seems overly restrictive.

@jonhoo
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 added a commit that referenced this issue Jun 24, 2017
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants