-
Notifications
You must be signed in to change notification settings - Fork 223
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
Make impl Debug for Rwlock simpler #423
Conversation
lock_api/src/rwlock.rs
Outdated
} | ||
} | ||
Some(guard) => d.field("data", &&*guard), | ||
None => d.field("data", &format_args!("<locked>")), |
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.
format_args!
is not needed here. field
accepts any &dyn Debug
which includes str
.
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.
Without format_args!
, the <locked>
will be wrapped with quotes, e.g.: Rwlock { data: "<locked>" }
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.
Can you add a comment that explains this? It is not obvious from looking at the code.
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.
Comment added
.finish() | ||
} | ||
} | ||
Some(guard) => d.field("data", &&*guard), |
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.
Is the &&*
really needed here? Can this just be &*
?
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.
Thanks! |
simple improvement