From 9eb547ec1ff5d44643266f2bbc7d872255458c26 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Tue, 25 Jun 2024 13:08:24 -0400 Subject: [PATCH] Don't show `.to_bits` in `Display` impl for `Entity` (#14011) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 https://github.com/bevyengine/bevy/pull/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 --- crates/bevy_ecs/src/entity/mod.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/crates/bevy_ecs/src/entity/mod.rs b/crates/bevy_ecs/src/entity/mod.rs index 5cefe6a1df53d..656687cdcd7a7 100644 --- a/crates/bevy_ecs/src/entity/mod.rs +++ b/crates/bevy_ecs/src/entity/mod.rs @@ -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()) } } @@ -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)); } }