Skip to content

Commit

Permalink
Adding #[derive(Debug)] to entity handles when debug_assertions is en…
Browse files Browse the repository at this point in the history
…abled
  • Loading branch information
recatek committed Aug 12, 2024
1 parent c4706c0 commit dea5aff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(crate) const ARCHETYPE_ID_BITS: u32 = ArchetypeId::BITS;
/// enable the `wrapping_version` crate feature instead. Note that this could
/// allow invalid entity access, but doing so will not access invalid memory,
/// and the chances of this happening are infinitesimally small.
#[cfg_attr(debug_assertions, derive(Debug))]
pub struct Entity<A: Archetype> {
inner: EntityAny,
_type: PhantomData<fn() -> A>,
Expand All @@ -52,6 +53,7 @@ pub struct Entity<A: Archetype> {
/// `wrapping_version` crate feature instead. Note that this could allow
/// invalid entity access, but doing so will not access invalid memory, and
/// the chances of this happening are infinitesimally small.
#[cfg_attr(debug_assertions, derive(Debug))]
pub struct EntityRaw<A: Archetype> {
inner: EntityRawAny,
_type: PhantomData<fn() -> A>,
Expand All @@ -64,6 +66,7 @@ pub struct EntityRaw<A: Archetype> {
/// generated by the `ecs_world!` declaration to convert the `EntityAny` into
/// an enum with each possible archetype outcome.
#[derive(Clone, Copy, Eq, PartialEq)]
#[cfg_attr(debug_assertions, derive(Debug))]
pub struct EntityAny {
key: u32, // [ slot_index (u24) | archetype_id (u8) ]
version: SlotVersion,
Expand All @@ -76,6 +79,7 @@ pub struct EntityAny {
/// generated by the `ecs_world!` declaration to convert the `EntityRawAny` into
/// an enum with each possible archetype outcome.
#[derive(Clone, Copy, Eq, PartialEq)]
#[cfg_attr(debug_assertions, derive(Debug))]
pub struct EntityRawAny {
key: u32, // [ dense_index (u24) | archetype_id (u8) ]
version: ArchetypeVersion,
Expand Down
2 changes: 2 additions & 0 deletions src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ const VERSION_START: NonZeroU32 = NonZeroU32::MIN;

#[repr(transparent)]
#[derive(Clone, Copy, Eq, PartialEq)]
#[cfg_attr(debug_assertions, derive(Debug))]
pub struct SlotVersion {
version: NonZeroU32,
}

#[repr(transparent)]
#[derive(Clone, Copy, Eq, PartialEq)]
#[cfg_attr(debug_assertions, derive(Debug))]
pub struct ArchetypeVersion {
version: NonZeroU32,
}
Expand Down

0 comments on commit dea5aff

Please sign in to comment.