Skip to content

Commit

Permalink
Don't show .to_bits in Display impl for Entity (#14011)
Browse files Browse the repository at this point in the history
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.

- 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).

I've updated an existing test to verify the output of `Entity::display`.

---------

Co-authored-by: Kristoffer Søholm <[email protected]>
  • Loading branch information
2 people authored and mockersf committed Jun 25, 2024
1 parent 8c1b9a6 commit 9eb547e
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,7 @@ impl<'de> Deserialize<'de> for Entity {

impl fmt::Display for Entity {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}v{}|{}",
self.index(),
self.generation(),
self.to_bits()
)
write!(f, "{}v{}", self.index(), self.generation())
}
}

Expand Down Expand Up @@ -1162,9 +1156,7 @@ mod tests {
fn entity_display() {
let entity = Entity::from_raw(42);
let string = format!("{}", entity);
let bits = entity.to_bits().to_string();
assert!(string.contains("42"));
assert!(string.contains("v1"));
assert!(string.contains(&bits));
}
}

0 comments on commit 9eb547e

Please sign in to comment.