diff options
author | HampusM <hampus@hampusmat.com> | 2024-06-20 22:04:31 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-06-20 22:04:31 +0200 |
commit | edb5eb812bb6a3e7ed26526fab24b110be3828d4 (patch) | |
tree | 9d8aaa1ba6467f0722b5e9f0424ed670ccb02047 /ecs/src | |
parent | 681fca5c465191e37714ed07937efec8b0c8b197 (diff) |
refactor(ecs): move down ArchetypeRefIter struct & impls in module
Diffstat (limited to 'ecs/src')
-rw-r--r-- | ecs/src/component/storage.rs | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/ecs/src/component/storage.rs b/ecs/src/component/storage.rs index 42e0e4f..cff50cf 100644 --- a/ecs/src/component/storage.rs +++ b/ecs/src/component/storage.rs @@ -16,37 +16,6 @@ pub struct Storage pending_archetype_lookup_entries: Vec<Vec<ComponentId>>, } -#[derive(Debug)] -pub struct ArchetypeRefIter<'component_storage> -{ - inner: SliceIter<'component_storage, usize>, - archetypes: &'component_storage [Archetype], -} - -impl<'component_storage> ArchetypeRefIter<'component_storage> -{ - fn new_empty() -> Self - { - Self { inner: [].iter(), archetypes: &[] } - } -} - -impl<'component_storage> Iterator for ArchetypeRefIter<'component_storage> -{ - type Item = &'component_storage Archetype; - - fn next(&mut self) -> Option<Self::Item> - { - let archetype_index = *self.inner.next()?; - - Some( - self.archetypes - .get(archetype_index) - .expect("Archetype index in archetype lookup entry was not found"), - ) - } -} - impl Storage { pub fn find_entities( @@ -185,6 +154,37 @@ pub struct Archetype pub components: Vec<Vec<EntityComponent>>, } +#[derive(Debug)] +pub struct ArchetypeRefIter<'component_storage> +{ + inner: SliceIter<'component_storage, usize>, + archetypes: &'component_storage [Archetype], +} + +impl<'component_storage> ArchetypeRefIter<'component_storage> +{ + fn new_empty() -> Self + { + Self { inner: [].iter(), archetypes: &[] } + } +} + +impl<'component_storage> Iterator for ArchetypeRefIter<'component_storage> +{ + type Item = &'component_storage Archetype; + + fn next(&mut self) -> Option<Self::Item> + { + let archetype_index = *self.inner.next()?; + + Some( + self.archetypes + .get(archetype_index) + .expect("Archetype index in archetype lookup entry was not found"), + ) + } +} + #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] struct ArchetypeComponentsHash { |