-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Simplify Debug display of DebugName
#21870
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
base: main
Are you sure you want to change the base?
Conversation
crates/bevy_utils/src/debug_info.rs
Outdated
| #[cfg(feature = "debug")] | ||
| write!(f, "{:?}", self.name.as_ref())?; | ||
| #[cfg(not(feature = "debug"))] | ||
| f.debug_struct("DebugName").finish()?; |
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.
Maybe tell the user they can enable the debug feature to read the actual name?
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.
Maybe tell the user they can enable the
debugfeature to read the actual name?
Yeah, that's a good idea! I had been trying to keep it consistent with the old version, but you're right that it's better to include the message. That also simplifies the implementation, since it can just use Deref.
ickshonpe
left a comment
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.
Looks good to me, maybe with the debug feature prompt suggested by janhohenheim.
Objective
As noted in #21856, the
Debugoutput ofDebugNameis too verbose. It is supposed to be a thin wrapper around a string, but it renders as astruct.Solution
Manually
impl Debug for DebugNameand write the string directly.Showcase
The following code
Prints the following before this change
And the following after it
When the
debugfeature is disabled, it prints the following both before and after the change