Friendlier Entity Debug impl
This commit is contained in:
parent
0ee937784e
commit
9ea7960544
@ -615,41 +615,19 @@ impl<'de> Deserialize<'de> for Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Outputs the full entity identifier, including the index, generation, and the raw bits.
|
/// Outputs the short entity identifier, including the index and generation.
|
||||||
///
|
///
|
||||||
/// This takes the format: `{index}v{generation}#{bits}`.
|
/// This takes the format: `{index}v{generation}`.
|
||||||
///
|
///
|
||||||
/// For [`Entity::PLACEHOLDER`], this outputs `PLACEHOLDER`.
|
/// For [`Entity::PLACEHOLDER`], this outputs `PLACEHOLDER`.
|
||||||
///
|
///
|
||||||
/// # Usage
|
/// For a unique [`u64`] representation, use [`Entity::to_bits`].
|
||||||
///
|
|
||||||
/// Prefer to use this format for debugging and logging purposes. Because the output contains
|
|
||||||
/// the raw bits, it is easy to check it against serialized scene data.
|
|
||||||
///
|
|
||||||
/// Example serialized scene data:
|
|
||||||
/// ```text
|
|
||||||
/// (
|
|
||||||
/// ...
|
|
||||||
/// entities: {
|
|
||||||
/// 4294967297: ( <--- Raw Bits
|
|
||||||
/// components: {
|
|
||||||
/// ...
|
|
||||||
/// ),
|
|
||||||
/// ...
|
|
||||||
/// )
|
|
||||||
/// ```
|
|
||||||
impl fmt::Debug for Entity {
|
impl fmt::Debug for Entity {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
if self == &Self::PLACEHOLDER {
|
if self == &Self::PLACEHOLDER {
|
||||||
write!(f, "PLACEHOLDER")
|
write!(f, "PLACEHOLDER")
|
||||||
} else {
|
} else {
|
||||||
write!(
|
write!(f, "{}v{}", self.index(), self.generation())
|
||||||
f,
|
|
||||||
"{}v{}#{}",
|
|
||||||
self.index(),
|
|
||||||
self.generation(),
|
|
||||||
self.to_bits()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user