Don't show .to_bits
in Display
impl for Entity
(#14011)
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 <k.soeholm@gmail.com>
This commit is contained in:
parent
8c1b9a6c18
commit
9eb547ec1f
@ -392,13 +392,7 @@ impl<'de> Deserialize<'de> for Entity {
|
|||||||
|
|
||||||
impl fmt::Display for Entity {
|
impl fmt::Display for Entity {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(
|
write!(f, "{}v{}", self.index(), self.generation())
|
||||||
f,
|
|
||||||
"{}v{}|{}",
|
|
||||||
self.index(),
|
|
||||||
self.generation(),
|
|
||||||
self.to_bits()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1162,9 +1156,7 @@ mod tests {
|
|||||||
fn entity_display() {
|
fn entity_display() {
|
||||||
let entity = Entity::from_raw(42);
|
let entity = Entity::from_raw(42);
|
||||||
let string = format!("{}", entity);
|
let string = format!("{}", entity);
|
||||||
let bits = entity.to_bits().to_string();
|
|
||||||
assert!(string.contains("42"));
|
assert!(string.contains("42"));
|
||||||
assert!(string.contains("v1"));
|
assert!(string.contains("v1"));
|
||||||
assert!(string.contains(&bits));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user