Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions crates/bevy_utils/src/debug_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const FEATURE_DISABLED: &str = "Enable the debug feature to see the name";
///
/// * If the `debug` feature is enabled, the actual name will be used
/// * If it is disabled, a string mentioning the disabled feature will be used
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq)]
pub struct DebugName {
#[cfg(feature = "debug")]
name: Cow<'static, str>,
Expand All @@ -23,12 +23,15 @@ pub struct DebugName {
cfg::alloc! {
impl fmt::Display for DebugName {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
#[cfg(feature = "debug")]
f.write_str(self.name.as_ref())?;
#[cfg(not(feature = "debug"))]
f.write_str(FEATURE_DISABLED)?;
// Deref to `str`, which will use `FEATURE_DISABLED` if necessary
write!(f, "{}", &**self)
}
}

Ok(())
impl fmt::Debug for DebugName {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
// Deref to `str`, which will use `FEATURE_DISABLED` if necessary
write!(f, "{:?}", &**self)
}
}
}
Expand Down
Loading