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

Add debug for btree_map::{Entry, VacantEntry, OccupiedEntry} #34885

Merged
merged 1 commit into from
Jul 20, 2016

Conversation

GuillaumeGomez
Copy link
Member

No description provided.

@@ -326,6 +326,15 @@ pub enum Entry<'a, K: 'a, V: 'a> {
OccupiedEntry<'a, K, V>),
}

impl<'a, K: 'a + Debug, V: 'a> Debug for Entry<'a, K: 'a, V: 'a> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be derived, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because OccupiedEntry.key method needs Ord trait.

@GuillaumeGomez GuillaumeGomez force-pushed the btree_map_debug branch 2 times, most recently from b30e4b6 to c1bd503 Compare July 17, 2016 17:08
impl<'a, K: 'a + Debug + Ord, V: 'a + Debug> Debug for Entry<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&Vacant(ref v) => write!(f, "Entry({:?})", v),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if these took into account the formatting parameters. You can probably use Formatter::debug_tuple for all of these.

@@ -326,6 +326,19 @@ pub enum Entry<'a, K: 'a, V: 'a> {
OccupiedEntry<'a, K, V>),
}

impl<'a, K: 'a + Debug + Ord, V: 'a + Debug> Debug for Entry<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Copy link
Contributor

@apasel422 apasel422 Jul 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these sorts of matches are usually written

match *self {
    Vacant(ref v) => ...
    Occupied(ref o) => ...
}

@GuillaumeGomez
Copy link
Member Author

Updated.

@@ -326,6 +326,19 @@ pub enum Entry<'a, K: 'a, V: 'a> {
OccupiedEntry<'a, K, V>),
}

impl<'a, K: 'a + Debug + Ord, V: 'a + Debug> Debug for Entry<'a, K, V> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these impls will need a stability marker.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I put it as unstable or directly as stable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per @alexcrichton's comments here, these can be stable.

@apasel422 apasel422 added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jul 18, 2016
@alexcrichton alexcrichton self-assigned this Jul 18, 2016
@alexcrichton
Copy link
Member

Discussed during libs triage the decision was to merge, thanks for the PR @GuillaumeGomez! Could you also tag these with #[stable] as well so we can keep track of when they were added?

@GuillaumeGomez
Copy link
Member Author

@alexcrichton: Your comment answered my question. Let's go for stable then! :)

@GuillaumeGomez GuillaumeGomez force-pushed the btree_map_debug branch 2 times, most recently from 1129ead to d5da1e9 Compare July 19, 2016 09:39
@GuillaumeGomez
Copy link
Member Author

Updated.

@alexcrichton
Copy link
Member

@bors: r+ dae311e

@bors
Copy link
Contributor

bors commented Jul 19, 2016

⌛ Testing commit dae311e with merge 48c2454...

bors added a commit that referenced this pull request Jul 19, 2016
Add debug for btree_map::{Entry, VacantEntry, OccupiedEntry}
@bors bors merged commit dae311e into rust-lang:master Jul 20, 2016
@GuillaumeGomez GuillaumeGomez deleted the btree_map_debug branch July 20, 2016 09:42
@apasel422 apasel422 added the relnotes Marks issues that should be documented in the release notes of the next release. label Jul 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants