-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
The Debug
implementation for Mutex
looks like this:
write!(f, "Mutex {{ data: {:?} }}", &*guard)
This is bad because it does not honor the #
pretty-print modifier.
println!("{:#?}", std::sync::Mutex::new(5));
It prints
Mutex { data: 5 }
instead of
Mutex {
data: 5
}
A correct implementation would use debug_struct
.
f.debug_struct("Mutex").field("data", &*guard).finish()
There seem to be lots of instances of this in the standard library. The following search is a good place to start.
grep -r ' {{ ' libcore libstd
zackmdavis, malbarbo, mcarton, scottmcm and oli-obk
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.