Skip to content

Commit 52e5ad5

Browse files
Don't show .to_bits in Display impl for Entity (#14011)
# Objective #12469 changed the `Debug` impl for `Entity`, making sure it's actually accurate for debugging. To ensure that its can still be readily logged in error messages and inspectors, this PR added a more concise and human-friendly `Display` impl. However, users found this form too verbose: the `to_bits` information was unhelpful and too long. Fixes #13980. ## Solution - Don't include `Entity::to_bits` in the `Display` implementation for `Entity`. This information can readily be accessed and logged for users who need it. - Also clean up the implementation of `Display` for `DebugName`, introduced in #13760, to simply use the new `Display` impl (since this was the desired format there). ## Testing I've updated an existing test to verify the output of `Entity::display`. --------- Co-authored-by: Kristoffer Søholm <[email protected]>
1 parent 4c3b4a4 commit 52e5ad5

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

crates/bevy_core/src/name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<'a> std::fmt::Display for DebugNameItem<'a> {
125125
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
126126
match self.name {
127127
Some(name) => std::fmt::Display::fmt(name, f),
128-
None => write!(f, "{}v{}", self.entity.index(), self.entity.generation()),
128+
None => std::fmt::Display::fmt(&self.entity, f),
129129
}
130130
}
131131
}

crates/bevy_ecs/src/entity/mod.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,7 @@ impl<'de> Deserialize<'de> for Entity {
392392

393393
impl fmt::Display for Entity {
394394
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
395-
write!(
396-
f,
397-
"{}v{}|{}",
398-
self.index(),
399-
self.generation(),
400-
self.to_bits()
401-
)
395+
write!(f, "{}v{}", self.index(), self.generation())
402396
}
403397
}
404398

@@ -1162,9 +1156,7 @@ mod tests {
11621156
fn entity_display() {
11631157
let entity = Entity::from_raw(42);
11641158
let string = format!("{}", entity);
1165-
let bits = entity.to_bits().to_string();
11661159
assert!(string.contains("42"));
11671160
assert!(string.contains("v1"));
1168-
assert!(string.contains(&bits));
11691161
}
11701162
}

0 commit comments

Comments
 (0)