-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
@@ -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> { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
b30e4b6
to
c1bd503
Compare
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), |
There was a problem hiding this comment.
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.
c1bd503
to
5e6b652
Compare
@@ -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 { |
There was a problem hiding this comment.
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) => ...
}
5e6b652
to
379fa21
Compare
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> { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Discussed during libs triage the decision was to merge, thanks for the PR @GuillaumeGomez! Could you also tag these with |
@alexcrichton: Your comment answered my question. Let's go for stable then! :) |
1129ead
to
d5da1e9
Compare
d5da1e9
to
dae311e
Compare
Updated. |
Add debug for btree_map::{Entry, VacantEntry, OccupiedEntry}
No description provided.