From 3a4eacbdee33a723f335132f2808686452dabbd8 Mon Sep 17 00:00:00 2001 From: Jonas Matser Date: Thu, 1 Oct 2020 19:58:21 +0200 Subject: [PATCH] Adds derive for missing debug implementations (#597) --- crates/bevy_app/src/event.rs | 3 ++- crates/bevy_core/src/time/time.rs | 1 + crates/bevy_ecs/hecs/src/archetype.rs | 2 ++ crates/bevy_ecs/hecs/src/borrow.rs | 1 + crates/bevy_ecs/hecs/src/entities.rs | 6 +++--- crates/bevy_ecs/hecs/src/world.rs | 1 + crates/bevy_ecs/src/resource/resource_query.rs | 3 +++ crates/bevy_ecs/src/system/query.rs | 1 + crates/bevy_ecs/src/system/system.rs | 2 +- crates/bevy_input/src/input.rs | 1 + 10 files changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/bevy_app/src/event.rs b/crates/bevy_app/src/event.rs index f9d144a130..1daf7f0456 100644 --- a/crates/bevy_app/src/event.rs +++ b/crates/bevy_app/src/event.rs @@ -43,7 +43,7 @@ enum State { /// /// // events are only processed once per reader /// assert_eq!(reader.iter(&events).count(), 0); -/// ``` +/// ``` /// /// # Details /// @@ -83,6 +83,7 @@ fn map_instance_event(event_instance: &EventInstance) -> &T { } /// Reads events of type `T` in order and tracks which events have already been read. +#[derive(Debug)] pub struct EventReader { last_event_count: usize, _marker: PhantomData, diff --git a/crates/bevy_core/src/time/time.rs b/crates/bevy_core/src/time/time.rs index 45f59978be..05323cfe6b 100644 --- a/crates/bevy_core/src/time/time.rs +++ b/crates/bevy_core/src/time/time.rs @@ -7,6 +7,7 @@ use instant::Instant; use std::time::Instant; /// Tracks elapsed time since the last update and since the App has started +#[derive(Debug)] pub struct Time { pub delta: Duration, pub instant: Option, diff --git a/crates/bevy_ecs/hecs/src/archetype.rs b/crates/bevy_ecs/hecs/src/archetype.rs index b5a9013c2e..6e2847aef1 100644 --- a/crates/bevy_ecs/hecs/src/archetype.rs +++ b/crates/bevy_ecs/hecs/src/archetype.rs @@ -35,6 +35,7 @@ use crate::{borrow::AtomicBorrow, query::Fetch, Access, Component, Query}; /// /// Accessing `Archetype`s is only required for complex dynamic scheduling. To manipulate entities, /// go through the `World`. +#[derive(Debug)] pub struct Archetype { types: Vec, state: HashMap, @@ -439,6 +440,7 @@ impl Drop for Archetype { } /// Metadata about a type stored in an archetype +#[derive(Debug)] pub struct TypeState { offset: usize, borrow: AtomicBorrow, diff --git a/crates/bevy_ecs/hecs/src/borrow.rs b/crates/bevy_ecs/hecs/src/borrow.rs index 8d1adad892..e8a9adff8d 100644 --- a/crates/bevy_ecs/hecs/src/borrow.rs +++ b/crates/bevy_ecs/hecs/src/borrow.rs @@ -22,6 +22,7 @@ use core::{ use crate::{archetype::Archetype, Component, MissingComponent}; +#[derive(Debug)] pub struct AtomicBorrow(AtomicUsize); impl AtomicBorrow { diff --git a/crates/bevy_ecs/hecs/src/entities.rs b/crates/bevy_ecs/hecs/src/entities.rs index bf26575dbd..66ce1ac1db 100644 --- a/crates/bevy_ecs/hecs/src/entities.rs +++ b/crates/bevy_ecs/hecs/src/entities.rs @@ -58,7 +58,7 @@ impl fmt::Debug for Entity { } } -#[derive(Default)] +#[derive(Debug, Default)] pub(crate) struct Entities { pub meta: Vec, // Reserved entities outside the range of `meta`, having implicit generation 0, archetype 0, and @@ -333,14 +333,14 @@ impl EntityReserver { } } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub(crate) struct EntityMeta { pub generation: u32, pub location: Location, } /// A location of an entity in an archetype -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub struct Location { /// The archetype index pub archetype: u32, diff --git a/crates/bevy_ecs/hecs/src/world.rs b/crates/bevy_ecs/hecs/src/world.rs index efdf627dc4..4613ffba79 100644 --- a/crates/bevy_ecs/hecs/src/world.rs +++ b/crates/bevy_ecs/hecs/src/world.rs @@ -38,6 +38,7 @@ use crate::{ /// /// The components of entities who have the same set of component types are stored in contiguous /// runs, allowing for extremely fast, cache-friendly iteration. +#[derive(Debug)] pub struct World { entities: Entities, index: HashMap, u32>, diff --git a/crates/bevy_ecs/src/resource/resource_query.rs b/crates/bevy_ecs/src/resource/resource_query.rs index 0b4acf7704..012116f965 100644 --- a/crates/bevy_ecs/src/resource/resource_query.rs +++ b/crates/bevy_ecs/src/resource/resource_query.rs @@ -47,6 +47,7 @@ impl<'a, T: Resource> Deref for ChangedRes<'a, T> { } /// Shared borrow of a Resource +#[derive(Debug)] pub struct Res<'a, T: Resource> { value: &'a T, } @@ -87,6 +88,7 @@ impl<'a, T: Resource> Deref for Res<'a, T> { } /// Unique borrow of a Resource +#[derive(Debug)] pub struct ResMut<'a, T: Resource> { _marker: PhantomData<&'a T>, value: *mut T, @@ -139,6 +141,7 @@ impl<'a, T: Resource> UnsafeClone for ResMut<'a, T> { /// Local resources are unique per-system. Two instances of the same system will each have their own resource. /// Local resources are automatically initialized using the FromResources trait. +#[derive(Debug)] pub struct Local<'a, T: Resource + FromResources> { value: *mut T, _marker: PhantomData<&'a T>, diff --git a/crates/bevy_ecs/src/system/query.rs b/crates/bevy_ecs/src/system/query.rs index 172e372e27..e184780c86 100644 --- a/crates/bevy_ecs/src/system/query.rs +++ b/crates/bevy_ecs/src/system/query.rs @@ -7,6 +7,7 @@ use bevy_tasks::ParallelIterator; use std::marker::PhantomData; /// Provides scoped access to a World according to a given [HecsQuery] +#[derive(Debug)] pub struct Query<'a, Q: HecsQuery> { pub(crate) world: &'a World, pub(crate) archetype_access: &'a ArchetypeAccess, diff --git a/crates/bevy_ecs/src/system/system.rs b/crates/bevy_ecs/src/system/system.rs index 87ec57e8c5..983190470f 100644 --- a/crates/bevy_ecs/src/system/system.rs +++ b/crates/bevy_ecs/src/system/system.rs @@ -35,7 +35,7 @@ pub trait System: Send + Sync { } /// Provides information about the archetypes a [System] reads and writes -#[derive(Default)] +#[derive(Debug, Default)] pub struct ArchetypeAccess { pub immutable: FixedBitSet, pub mutable: FixedBitSet, diff --git a/crates/bevy_input/src/input.rs b/crates/bevy_input/src/input.rs index 58583974f7..72876dcd2d 100644 --- a/crates/bevy_input/src/input.rs +++ b/crates/bevy_input/src/input.rs @@ -2,6 +2,7 @@ use bevy_utils::HashSet; use std::hash::Hash; /// A "press-able" input of type `T` +#[derive(Debug)] pub struct Input { pressed: HashSet, just_pressed: HashSet,